[Win32utils-devel] Asynchronous Pipe::Server problems

Heesob Park phasis at gmail.com
Tue May 20 04:15:29 EDT 2008


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:

--- 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

       # Returns whether or not there is a pending IO operation on the pipe.
@@ -76,6 +75,7 @@
       #
       def read
          bytes = [0].pack('L')
+         @buffer        = 0.chr * PIPE_BUFFER_SIZE
          if @asynchronous
             bool = ReadFile(@pipe, @buffer, @buffer.size, bytes, @overlapped)

@@ -83,13 +83,13 @@

             if bool && bytes_read > 0
                @pending_io = false
-               @buffer[bytes_read] = 0
+               @buffer = @buffer[0,bytes_read]
                return true
             end

             error = GetLastError()
             if !bool && error == ERROR_IO_PENDING
-               @pending = true
+               @pending_io = true
                return true
             end



--- win32-pipe/lib/win32/pipe/server.rb 2008-05-20 14:10:30.000000000 +0900
+++ server.rb   2008-05-20 16:54:23.000000000 +0900
@@ -9,13 +9,10 @@
          super(name, asynchronous)

          @open_mode = PIPE_ACCESS_DUPLEX
-         @pipe_mode = PIPE_TYPE_BYTE | PIPE_READMODE_BYTE
+         @pipe_mode = PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT

          if @asynchronous
-            @pipe_mode |= PIPE_NOWAIT
             @open_mode |= FILE_FLAG_OVERLAPPED
-         else
-            @pipe_mode |= PIPE_WAIT
          end




Regards,

Park Heesob


More information about the win32utils-devel mailing list