X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fsend.c;h=26c7a27011109ae7d2756583d0d639a866a71245;hb=7ef6c64e210ac0979d7e8ac69bc5b5208c2405ab;hp=d8a876ec3bf3bd8f1f8d65eeab39d0bd1fe636ab;hpb=d60f3b0c6b0f93a601acd1cfd3923f94ca05abb0;p=gnulib.git diff --git a/lib/send.c b/lib/send.c index d8a876ec3..26c7a2701 100644 --- a/lib/send.c +++ b/lib/send.c @@ -1,6 +1,6 @@ /* send.c --- wrappers for Windows send 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 @@ ssize_t rpl_send (int fd, const void *buf, size_t len, int flags) { SOCKET sock = FD_TO_SOCKET (fd); - int r = send (sock, buf, len, flags); - if (r < 0) - set_winsock_errno (); - return r; + if (sock == INVALID_SOCKET) + { + errno = EBADF; + return -1; + } + else + { + int r = send (sock, buf, len, flags); + if (r < 0) + set_winsock_errno (); + + return r; + } }