instance method
OpenSSL::Buffering#do_write
(untyped s) -> untyped
do_write(s)
ext/openssl/lib/openssl/buffering.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/ext/openssl/lib/openssl/buffering.rb, line 349
def do_write(s)
@wbuffer = Buffer.new unless defined? @wbuffer
@wbuffer.append_as_bytes(s)
@sync ||= false
buffer_size = @wbuffer.bytesize
if @sync or buffer_size > BLOCK_SIZE
nwrote = 0
begin
while nwrote < buffer_size do
begin
chunk = if nwrote > 0
@wbuffer.byteslice(nwrote, @wbuffer.bytesize)
else
@wbuffer
end
nwrote += syswrite(chunk)
rescue Errno::EAGAIN
retry
end
end
ensure
if nwrote < @wbuffer.bytesize
@wbuffer[0, nwrote] = ""
else
@wbuffer.clear
end
end
end
end
Writes s to the buffer. When the buffer is full or sync is true the buffer is flushed to the underlying socket.