On Fri, Jan 14, 2011 at 4:47 PM, Stephen Bannasch
<stephen.bannasch / deanbrook.org> wrote:
> At 6:49 AM +0900 1/15/11, ghazel / gmail.com wrote:
>>On Thu, Jan 13, 2011 at 10:03 PM, U.Nakamura <usa / garbagecollect.jp> wrote:
>>> Hello,
>>>
>>> In message "[ruby-core:34485] Re: Windows sockets and CRT fds"
>>>  on Jan.14,2011 13:35:42, <ghazel / gmail.com> wrote:
>>>> I understand it would have to be rewritten to change it, but why was
>>>> it written that way to begin with? Aside from the effort to change it,
>>>> is there anything lost or gained by switching?
>>>
>>> Q: why was it written that way to begin with?
>>> A: Sorry, I don't know. I guess that the author might not want
>>>  to put many #ifdef-s into ruby core source.
>>
>>win32.c and win32.h have a ton of ifdefs in them. What I'm proposing
>>would remove many of them, and not add any to the rest of Ruby code.
>>Who is the author of the _open_osfhandle code?
>
> [Sometimes I find playing with git a bit like a crossword puzzle ... there's almost always some way to do what I want ...]
>
> Here's a summary of all the locations in win32/win32.c that reference open_osfhandle.

Thank you for encouraging me to dig. The use of _open_osfhandle I'm
referring to dates back to 2000-11-15 when it was added with this
helpful comment:

C:\ruby\win32>svn log -r 1040
------------------------------------------------------------------------
r1040 | matz | 2000-11-15 23:24:21 -0800 (Wed, 15 Nov 2000) | 2 lines

matz

------------------------------------------------------------------------

I believe, from reading the commit, that the intention was to
implement fddup. It seems according to this next commit though, that
fddup was removed and the need for it disappeared in ruby 1.7:

C:\ruby\win32>svn log -r 2916
------------------------------------------------------------------------
r2916 | nobu | 2002-10-01 08:26:39 -0700 (Tue, 01 Oct 2002) | 7 lines

        * ext/socket/socket.c (init_sock): no need for special finalizer,
          socket descriptor is no longer duplicated in 1.7.
          [ruby-talk:50732]

        * win32/win32.c, win32/win32.h (rb_w32_fddup, rb_w32_fdclose):
          delete.

------------------------------------------------------------------------

So it really looks like the use of _open_osfhandle with sockets is no
longer needed.

-Greg