Recvfrom(2) error on OS X 10.3.2

With regard to [ruby-talk:89962], I glanced through the code and it
looks like a bug in ext/socket.c

					FUKUMOTO Atsushi
					fukumoto@nospam.imasy.or.jp

Index: socket.c

···

===================================================================
RCS file: /src/ruby/ext/socket/socket.c,v
retrieving revision 1.110
diff -u -r1.110 socket.c
— socket.c 10 Jan 2004 17:52:38 -0000 1.110
+++ socket.c 20 Jan 2004 13:56:51 -0000
@@ -416,6 +416,7 @@
char buf[1024];
socklen_t alen = sizeof buf;
VALUE len, flg;

  • long buflen;
    long slen;
    int fd, flags;

@@ -430,13 +431,13 @@
}
fd = fileno(fptr->f);

  • slen = NUM2INT(len);
  • str = rb_tainted_str_new(0, slen);
  • buflen = NUM2INT(len);
  • str = rb_tainted_str_new(0, buflen);

retry:
rb_thread_wait_fd(fd);
TRAP_BEG;

  • slen = recvfrom(fd, RSTRING(str)->ptr, slen, flags, (struct sockaddr*)buf, &alen);
  • slen = recvfrom(fd, RSTRING(str)->ptr, buflen, flags, (struct sockaddr*)buf, &alen);
    TRAP_END;

    if (slen < 0) {

Thanks for the patch! I now no longer receive Errno::EINVAL errors. I
do occasionally get EAGAIN errors now - is that normal?

Thanks,

Nathaniel

P.S. Can someone merge the patch?

<:((><

···

On Jan 20, 2004, at 09:06, fukumoto@nospam.imasy.or.jp wrote:

With regard to [ruby-talk:89962], I glanced through the code and it
looks like a bug in ext/socket.c

Are you using non-blocking IO?

···

On Wed, Jan 21, 2004 at 12:59:50AM +0900, Nathaniel Talbott wrote:

On Jan 20, 2004, at 09:06, fukumoto@nospam.imasy.or.jp wrote:

With regard to [ruby-talk:89962], I glanced through the code and it
looks like a bug in ext/socket.c

Thanks for the patch! I now no longer receive Errno::EINVAL errors. I
do occasionally get EAGAIN errors now - is that normal?


_ _

__ __ | | ___ _ __ ___ __ _ _ __
'_ \ / | __/ __| '_ _ \ / ` | ’ \
) | (| | |
__ \ | | | | | (| | | | |
.__/ _,
|_|/| || ||_,|| |_|
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

Software is like sex; it’s better when it’s free.
– Linus Torvalds

I believe DRb does underneath. I just find the EAGAIN error surprising
as I don’t get it on the other platforms I’ve tested under.

Nathaniel

<:((><

···

On Jan 20, 2004, at 12:00, Mauricio Fernández wrote:

On Wed, Jan 21, 2004 at 12:59:50AM +0900, Nathaniel Talbott wrote:

Thanks for the patch! I now no longer receive Errno::EINVAL errors. I
do occasionally get EAGAIN errors now - is that normal?

Are you using non-blocking IO?