Sha256: 89243202964a158c3c4091f664b3e2cb8233ef0366d13bd60f6f1b148011d9a8

Contents?: true

Size: 1.07 KB

Versions: 6

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

require 'openssl'

import('./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)
    read_watcher = nil
    write_watcher = nil
    loop do
      case (result = read_nonblock(maxlen, buf, exception: false))
      when :wait_readable then (read_watcher ||= io.read_watcher).await
      when :wait_writable then (write_watcher ||= io.write_watcher).await
      else result
      end
    end
  end

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

  def syswrite(buf)
    read_watcher = nil
    write_watcher = nil
    loop do
      case (result = write_nonblock(buf, exception: false))
      when :wait_readable then (read_watcher ||= io.read_watcher).await
      when :wait_writable then (write_watcher ||= io.write_watcher).await
      else result
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
polyphony-0.36 lib/polyphony/extensions/openssl.rb
polyphony-0.34 lib/polyphony/extensions/openssl.rb
polyphony-0.33 lib/polyphony/extensions/openssl.rb
polyphony-0.32 lib/polyphony/extensions/openssl.rb
polyphony-0.31 lib/polyphony/extensions/openssl.rb
polyphony-0.30 lib/polyphony/extensions/openssl.rb