Class: RightScale::Windows::PipeServer

Inherits:
Win32::Pipe::Server
  • Object
show all
Defined in:
lib/chef/windows/pipe_server.rb

Overview

Provides a generic Windows named pipe server based on eventmachine.

Instance Method Summary collapse

Instance Method Details

#closeObject

Closes temporary file before closing pipe.



271
272
273
274
275
276
277
# File 'lib/chef/windows/pipe_server.rb', line 271

def close
  if @temp_file
    @temp_file.close
    @temp_file = nil
  end
  super.close
end

#disconnectObject

Hack which fixes a bug with pending write never resetting pending_io flag, causing state machine never to reenter waiting state. also resets buffer which can be set to a small size by a tiny overlapped I/O operation.



264
265
266
267
268
# File 'lib/chef/windows/pipe_server.rb', line 264

def disconnect
  @pending_io = false
  @buffer     = 0.chr * PIPE_BUFFER_SIZE
  super
end

#filenoObject

Hack which allows eventmachine to schedule I/O for this non-Ruby IO object. EM needs a real file number, so this method uses a temporary file.

Returns

fileno(Integer)

temporary file’s file number.



255
256
257
258
# File 'lib/chef/windows/pipe_server.rb', line 255

def fileno
  @temp_file = Tempfile.new("RS-pipe-server") unless @temp_file
  return @temp_file.fileno
end