Ruby 1.7 Win32 socket bug fix

Hello all,

After quite some debugging, I found the trouble with the Win32 socket
extension. I hope someone will implement the fix because I don’t know
how to send a patch (and I’m lazy :slight_smile: )

In win32/win32.c, there are a lot of lines like this:

RUBY_CRITICAL(r = recv (TO_SOCKET(s), buf, len, flags));
if (r == SOCKET_ERROR)
errno = WSAGetLastError();

The problem lies in RUBY_CRITICAL. Code is being executed at the end
of this macro that for some reason sets the value returned by
WSAGetLastError to 0 (or it sets another error value, whatever.)

Solution: include the errorhandling in RUBY_CRITICAL, which is more
threadsafe too:

RUBY_CRITICAL(
	r = recv (TO_SOCKET(s), buf, len, flags);
	if (r == SOCKET_ERROR)
		errno = WSAGetLastError();
);

The thing that broke sockets in the first place is probably hidden in
rb_w32_leave_critical, but the code there scares me.

Danny
http://froukepc.dhs.org/rudl/

Hello,

At Sep.29,2002 05:49:14, danny@froukepc.dhs.org wrote on
“Ruby 1.7 Win32 socket bug fix” :

After quite some debugging, I found the trouble with the Win32 socket
extension. I hope someone will implement the fix because I don’t know
how to send a patch (and I’m lazy :slight_smile: )

Thank you for your report.
I’ll commit later.

You can send patches to ruby-bugs@ruby-lang.org.
Since ruby-talk has much flux (and I’m not good at reading
English), I often overlook such reports ;-(

···


U.Nakamura usa@osb.att.ne.jp