diff options
Diffstat (limited to 'ext/socket/socket.c')
-rw-r--r-- | ext/socket/socket.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/ext/socket/socket.c b/ext/socket/socket.c index 3605e991f0..37094026e4 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -373,10 +373,14 @@ s_recv(sock, argc, argv, from) if (flg == Qnil) flags = 0; else flags = NUM2INT(flg); - str = rb_str_new(0, NUM2INT(len)); - GetOpenFile(sock, fptr); + if (rb_read_pending(fptr->f)) { + rb_raise(rb_eIOError, "recv for buffered IO"); + } fd = fileno(fptr->f); + + str = rb_str_new(0, NUM2INT(len)); + rb_thread_wait_fd(fd); TRAP_BEG; retry: |