On Sun, Jan 16, 2011 at 4:51 PM, U.Nakamura <usa / garbagecollect.jp> wrote:
>> I'm not sure which parts you're saying need to be rewritten for Unix
>> and Windows. Currently there needs to be different code for Unix and
>> Windows, because a socket handle you might come across on Windows has
>> to be adapted to the sort of fd that ruby uses. After the hypothetical
>> switch to using regular Windows sockets in Ruby, you could take a
>> socket handle from anywhere and select on it in Ruby and have no
>> Windows specific code (except inside of Ruby). So, I only see it
>> reducing the amount of platform specific code (and bugs) in
>> extensions.
>
> If you think so, could you show the patch that shows the concept?
> Especially, I want know how about the main body of ruby, ext/socket,
> and ext/openssl.

Those will not change. It would only affect the Win32 code. If I make
a patch against 1.8.7, assuming everyone likes it, is there any hope
of it being accepted for 1.8.7 or 1.8.8?

The problem is even worse in Ruby 1.9. IS_SOCKET() checks whether the
handle is in an internal list or not, so the socket created by
libmysql will not appear to be a socket, and there is nothing the
extension writer can do to work around that since the list is not
exposed in any way.. Thankfully 1.9 has rb_thread_blocking_region so
the extension writer can use real select(), but there is no way to
write it to be compatible with both versions without an ifdef. I could
write a patch which fixes this for 1.9 as well, if the 1.8 patch is
accepted.

-Greg