Sha256: d113307986914143dadb116c107bc135147c9d3cde7dfcf446727285f7b43356

Contents?: true

Size: 1004 Bytes

Versions: 2

Compression:

Stored size: 1004 Bytes

Contents

# frozen_string_literal: true

require 'openssl'

require_relative './socket'

# Open ssl socket helper methods (to make it compatible with Socket API)
class ::OpenSSL::SSL::SSLSocket
  def dont_linger
    io.dont_linger
  end

  def no_delay
    io.no_delay
  end

  def reuse_addr
    io.reuse_addr
  end

  def sysread(maxlen, buf)
    loop do
      case (result = read_nonblock(maxlen, buf, exception: false))
      when :wait_readable then Thread.current.agent.wait_io(io, false)
      when :wait_writable then Thread.current.agent.wait_io(io, true)
      else result
      end
    end
  end

  def flush
    # osync = @sync
    # @sync = true
    # do_write ""
    # return self
    # ensure
    # @sync = osync
  end

  def syswrite(buf)
    loop do
      case (result = write_nonblock(buf, exception: false))
      when :wait_readable then Thread.current.agent.wait_io(io, false)
      when :wait_writable then Thread.current.agent.wait_io(io, true)
      else result
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
polyphony-0.42 lib/polyphony/extensions/openssl.rb
polyphony-0.41 lib/polyphony/extensions/openssl.rb