[Win32utils-devel] Asynchronous Pipe::Server problems
Park Heesob
phasis at gmail.com
Tue May 20 10:25:20 EDT 2008
----- Original Message -----
From: "Daniel Berger" <djberg96 at gmail.com>
To: "Development and ideas for win32utils projects" <win32utils-devel at rubyforge.org>
Sent: Tuesday, May 20, 2008 8:45 PM
Subject: Re: [Win32utils-devel] Asynchronous Pipe::Server problems
> Heesob Park wrote:
>> 2008/5/20 Daniel Berger <djberg96 at gmail.com>:
>>> Heesob Park wrote:
>>>> Hi,
>>>>
>>>> 2008/5/20 Daniel Berger <djberg96 at gmail.com>:
>>>>> Hi all,
>>>>>
>> <snip>
>>> However, I've botched something else up. I started up the
>>> test_async_server.rb program in one terminal, then ran the
>>> test_client_async.rb program. The first time it works on the client side:
>>>
>>> # Client side
>>> Connected...
>>> write_complete
>>> pipe client is running
>>> read_complete
>>> Got [Ruby rocks!] back from server
>>>
>>> Though I see nothing on the server side.
>>>
>>> The second time I run the client it just hangs.
>>>
>>> I fixed something in the Pipe#wait method (so update from CVS) but that
>>> didn't solve it.
>>>
>>> Any ideas?
>>>
>> Here is the patch for pipe.rb and server.rb:
>
> <snip>
>
> Excellent, thanks!
>
>> --- win32-pipe/lib/win32/pipe.rb 2008-05-20 14:10:30.000000000 +0900
>> +++ pipe.rb 2008-05-20 17:07:53.000000000 +0900
>> @@ -62,7 +61,7 @@
>> #
>> def close
>> DisconnectNamedPipe(@pipe)
>> - CloseHandle(@pipe)
>> + # CloseHandle(@pipe)
>> end
>
> I can see why we don't do this now, but I wonder if we should do this in
> a finalizer, along with a call to FlushFileBuffers(). All the example
> code I see closes the handle. Perhaps I'm being overly paranoid about
> handle leaks, though.
>
> I'm also thinking about adding a block form that would automatically
> ensure a call to Pipe#close.
>
> What do you think?
>
The problem is due to the reconnect method.
The solution is define disconnect as DisconnectNamedPipe ,close as before
and modify
def reconnect
close
mainloop
end
to
def reconnect
disconnect
mainloop
end
Regards,
Park Heesob
More information about the win32utils-devel
mailing list