diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 2000-08-16 23:53:42 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 2000-08-16 23:53:42 +0000 |
commit | d3d49e297818ad29e57e852d02bbe2b2bab8a74c (patch) | |
tree | 3a57e9eeadc391af22446f2d06bacd7b1b14a0d5 /win32/win32sck.c | |
parent | 7a9556019f9c4641b3caa83c80f9a1ded5afaaa8 (diff) | |
download | perl-d3d49e297818ad29e57e852d02bbe2b2bab8a74c.tar.gz |
change#6328 could make close(SOCKET) return false on windows
when it shouldn't
p4raw-link: @6328 on //depot/perl: 4e94524934c1af4124b2888d9716e5304ee50ad9
p4raw-id: //depot/perl@6657
Diffstat (limited to 'win32/win32sck.c')
-rw-r--r-- | win32/win32sck.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/win32/win32sck.c b/win32/win32sck.c index f7d101bc8b..0ce53c376b 100644 --- a/win32/win32sck.c +++ b/win32/win32sck.c @@ -426,15 +426,24 @@ my_fclose (FILE *pf) if (!wsock_started) /* No WinSock? */ return(fclose(pf)); /* Then not a socket. */ osf = TO_SOCKET(fileno(pf));/* Get it now before it's gone! */ - if (osf != -1 - && closesocket(osf) == SOCKET_ERROR - && WSAGetLastError() != WSAENOTSOCK) - { - (void)fclose(pf); - return EOF; + if (osf != -1) { + int err; + win32_fflush(pf); + err = closesocket(osf); + if (err == 0) { + (void)fclose(pf); /* handle already closed, ignore error */ + return 0; + } + else if (err == SOCKET_ERROR) { + err = WSAGetLastError(); + if (err != WSAENOTSOCK) { + (void)fclose(pf); + errno = err; + return EOF; + } + } } - else - return fclose(pf); + return fclose(pf); } struct hostent * |