X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Flisten.c;h=40b6b50c23fb54de83fcb3201c83c2781a5c7f89;hb=cd56634a4a8179fd5a4419fbb3e27211b042ab1c;hp=938aa7546037c43118be56860da5234c5cf6731f;hpb=d60f3b0c6b0f93a601acd1cfd3923f94ca05abb0;p=gnulib.git diff --git a/lib/listen.c b/lib/listen.c index 938aa7546..40b6b50c2 100644 --- a/lib/listen.c +++ b/lib/listen.c @@ -1,6 +1,6 @@ /* listen.c --- wrappers for Windows listen function - Copyright (C) 2008-2011 Free Software Foundation, Inc. + Copyright (C) 2008-2014 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; + } }