X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Faccept.c;h=8775aaee2d8c5305c342fbaa757db4a5e5ec77ac;hb=96269bbd2c9c35940341c978261587bdf3bcda78;hp=ae46537792b369e4814e7c7e24b36620f351b085;hpb=11ee0e1340f95ccb9954e522f6e003b3125eb109;p=gnulib.git diff --git a/lib/accept.c b/lib/accept.c index ae4653779..8775aaee2 100644 --- a/lib/accept.c +++ b/lib/accept.c @@ -1,6 +1,6 @@ /* accept.c --- wrappers for Windows accept function - Copyright (C) 2008 Free Software Foundation, Inc. + Copyright (C) 2008-2012 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -29,14 +29,24 @@ #undef accept int -rpl_accept (int fd, struct sockaddr *addr, int *addrlen) +rpl_accept (int fd, struct sockaddr *addr, socklen_t *addrlen) { - SOCKET fh = accept (FD_TO_SOCKET (fd), addr, addrlen); - if (fh == INVALID_SOCKET) + SOCKET sock = FD_TO_SOCKET (fd); + + if (sock == INVALID_SOCKET) { - set_winsock_errno (); + errno = EBADF; return -1; } else - return SOCKET_TO_FD (fh); + { + SOCKET fh = accept (sock, addr, addrlen); + if (fh == INVALID_SOCKET) + { + set_winsock_errno (); + return -1; + } + else + return SOCKET_TO_FD (fh); + } }