diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-02-13 05:09:11 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-02-13 05:09:11 +0000 |
commit | 8be410f0653bfb22970381447acf685af4795c00 (patch) | |
tree | 8946eb2e9437f998c332d5d7326032efce9dd141 /ext/socket/socket.c | |
parent | 32ce4317d8077c926d0c00172cfac8001dd5ff98 (diff) |
* io.c (rb_io_ctl): do not call ioctl/fcntl for f2, if f and f2
have same fileno.
* eval.c (rb_load): raise LocaJumpError if unexpected local jumps
appear during load.
* ext/socket/socket.c (bsock_close_read): don't call rb_thread_fd_close();
it's supposed to be called by io_io_close().
* ext/socket/socket.c (bsock_close_read): do not modify f and f2.
* ext/socket/socket.c (bsock_close_write): ditto.
* ext/socket/socket.c (sock_new): avoid dup(2) on sockets.
* parse.y (primary): preserve and clear in_single and in_def using
stack to prevent nested method errors in singleton class bodies.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1177 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket/socket.c')
-rw-r--r-- | ext/socket/socket.c | 20 |
1 files changed, 2 insertions, 18 deletions
diff --git a/ext/socket/socket.c b/ext/socket/socket.c index 1ef2e894f0..891a354929 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -182,9 +182,7 @@ sock_new(class, fd) fp->f = rb_fdopen(fd, "r"); #ifdef NT fp->finalize = sock_finalize; - fd = myfddup(fd); #else - fd = dup(fd); #endif fp->f2 = rb_fdopen(fd, "w"); fp->mode = FMODE_READWRITE; @@ -233,18 +231,10 @@ bsock_close_read(sock) } GetOpenFile(sock, fptr); shutdown(fileno(fptr->f), 0); - if (fptr->f2 == 0) { + if (!(fptr->mode & FMODE_WRITABLE)) { return rb_io_close(sock); } - rb_thread_fd_close(fileno(fptr->f)); fptr->mode &= ~FMODE_READABLE; -#ifdef NT - myfdclose(fptr->f); -#else - fclose(fptr->f); -#endif - fptr->f = fptr->f2; - fptr->f2 = 0; return Qnil; } @@ -259,17 +249,11 @@ bsock_close_write(sock) rb_raise(rb_eSecurityError, "Insecure: can't close socket"); } GetOpenFile(sock, fptr); - if (fptr->f2 == 0) { + if (!(fptr->mode & FMODE_READABLE)) { return rb_io_close(sock); } shutdown(fileno(fptr->f2), 1); fptr->mode &= ~FMODE_WRITABLE; -#ifdef NT - myfdclose(fptr->f2); -#else - fclose(fptr->f2); -#endif - fptr->f2 = 0; return Qnil; } |