diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1999-02-12 11:17:06 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1999-02-12 11:17:06 +0000 |
commit | 42c802126215101feed36135ba8f9601895ec03a (patch) | |
tree | fde428b1886469b75e73222107e2ee5fdc798ef3 /ext | |
parent | 997ff23758884944f28a089eaa50ac7eb1c026c6 (diff) |
990212
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_3@400 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r-- | ext/socket/socket.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/ext/socket/socket.c b/ext/socket/socket.c index e9bdbc9e8c..875c8aa5fb 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -96,6 +96,8 @@ sock_new(class, fd) fp->f = rb_fdopen(fd, "r"); #ifdef NT fp->finalize = sock_finalize; +#else + fd = dup(fd); #endif fp->f2 = rb_fdopen(fd, "w"); fp->mode = FMODE_READWRITE; @@ -140,11 +142,13 @@ bsock_close_read(sock) rb_secure(4); GetOpenFile(sock, fptr); + shutdown(fileno(fptr->f), 0); if (fptr->f2 == 0) { return rb_io_close(sock); } - if (shutdown(fileno(fptr->f), 0) == -1) - rb_sys_fail(0); +#ifdef USE_THREAD + rb_thread_fd_close(fileno(fptr->f)); +#endif fptr->mode &= ~FMODE_READABLE; #ifdef NT free(fptr->f); @@ -168,8 +172,7 @@ bsock_close_write(sock) if (fptr->f2 == 0) { return rb_io_close(sock); } - if (shutdown(fileno(fptr->f), 1) == -1) - rb_sys_fail(0); + shutdown(fileno(fptr->f2), 1); fptr->mode &= ~FMODE_WRITABLE; #ifdef NT free(fptr->f2); |