X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Flisten.c;h=0ca834628e29d61407f960ef41a499f25862c1fe;hb=43593319b31e6b0175b8eec4433bac744959822d;hp=4a77de22ea240b37736cb4454e0daf1aa805ae5a;hpb=b2e2010c7c902235b5efb5bd3c6529f61b093aa4;p=gnulib.git diff --git a/lib/listen.c b/lib/listen.c index 4a77de22e..0ca834628 100644 --- a/lib/listen.c +++ b/lib/listen.c @@ -1,6 +1,6 @@ /* listen.c --- wrappers for Windows listen function - Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 2008-2013 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; + } }