summaryrefslogtreecommitdiff
path: root/win32/win32sck.c
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>2000-08-16 23:53:42 +0000
committerGurusamy Sarathy <gsar@cpan.org>2000-08-16 23:53:42 +0000
commitd3d49e297818ad29e57e852d02bbe2b2bab8a74c (patch)
tree3a57e9eeadc391af22446f2d06bacd7b1b14a0d5 /win32/win32sck.c
parent7a9556019f9c4641b3caa83c80f9a1ded5afaaa8 (diff)
downloadperl-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.c25
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 *