X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Flisten.c;h=b7d070e64bcde9edc598e1994694cc721bdf1652;hb=cea318a913148d825c03a4e45f4553e4cb4e2880;hp=49e0a08425e681c0afd867e710d92e01f19b2947;hpb=11ee0e1340f95ccb9954e522f6e003b3125eb109;p=gnulib.git diff --git a/lib/listen.c b/lib/listen.c index 49e0a0842..b7d070e64 100644 --- a/lib/listen.c +++ b/lib/listen.c @@ -1,6 +1,6 @@ /* listen.c --- wrappers for Windows listen function - Copyright (C) 2008 Free Software Foundation, Inc. + Copyright (C) 2008-2011 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 @@ -32,9 +32,18 @@ int rpl_listen (int fd, int backlog) { SOCKET sock = FD_TO_SOCKET (fd); - int r = listen (sock, backlog); - if (r < 0) - set_winsock_errno (); - return r; + if (sock == INVALID_SOCKET) + { + errno = EBADF; + return -1; + } + else + { + int r = listen (sock, backlog); + if (r < 0) + set_winsock_errno (); + + return r; + } }