diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-12-09 23:39:57 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-12-09 23:39:57 +0000 |
commit | bb59e412e1a37124d8ba14c4ab19caea75f54233 (patch) | |
tree | 86dd3b9367cb55aa4576f78467550bd1fbc9b028 | |
parent | d9a56b4feedb4d85b5b867e537a3e94acacd42e1 (diff) | |
download | ruby-bb59e412e1a37124d8ba14c4ab19caea75f54233.tar.gz |
* ext/socket/socket.c (sock_listen): get OpenFile just before calling
listen(2).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7527 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | ext/socket/socket.c | 4 | ||||
-rw-r--r-- | test/socket/test_socket.rb | 14 |
3 files changed, 22 insertions, 1 deletions
@@ -1,3 +1,8 @@ +Fri Dec 10 08:39:48 2004 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * ext/socket/socket.c (sock_listen): get OpenFile just before calling + listen(2). + Thu Dec 9 16:28:35 2004 NAKAMURA Usaku <usa@ruby-lang.org> * ext/sdbm/init.c (GetDBM): typo. diff --git a/ext/socket/socket.c b/ext/socket/socket.c index 83a70b203d..ac2cac8809 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -2013,10 +2013,12 @@ sock_listen(sock, log) VALUE sock, log; { OpenFile *fptr; + int backlog; rb_secure(4); + backlog = NUM2INT(log); GetOpenFile(sock, fptr); - if (listen(fptr->fd, NUM2INT(log)) < 0) + if (listen(fptr->fd, backlog) < 0) rb_sys_fail("listen(2)"); return INT2FIX(0); diff --git a/test/socket/test_socket.rb b/test/socket/test_socket.rb index c436484dde..11d688ba75 100644 --- a/test/socket/test_socket.rb +++ b/test/socket/test_socket.rb @@ -57,4 +57,18 @@ class TestBasicSocket < Test::Unit::TestCase } end end + + def test_listen + s = nil + log = Object.new + class << log; self end.send(:define_method, :to_int) { + s.close + 2 + } + inet_stream do |s| + assert_raise(IOError) { + s.listen(log) + } + end + end end if defined?(Socket) |