lib/rev/buffered_io.rb in rev-0.1.2 vs lib/rev/buffered_io.rb in rev-0.1.3
- old
+ new
@@ -86,35 +86,31 @@
# Attempt to write the contents of the output buffer
def write_output_buffer
return if @write_buffer.empty?
- @write_buffer.write_to(@io)
+ begin
+ @write_buffer.write_to(@io)
+ rescue Errno::EPIPE
+ return close
+ end
+
return unless @write_buffer.empty?
@writer.disable if @writer and @writer.enabled?
on_write_complete
end
-
- # Wrapper for handling reset connections and EAGAIN
- def write_nonblock(data)
- begin
- @io.write_nonblock(data)
- rescue Errno::ECONNRESET, Errno::EPIPE
- close
- rescue Errno::EAGAIN
- end
- end
# Inherited callback from IOWatcher
def on_readable
begin
on_read @io.read_nonblock(INPUT_SIZE)
rescue Errno::ECONNRESET, EOFError
close
end
end
-
+
+ # Schedule a write to be performed when the IO object becomes writable
def schedule_write
return if @writer and @writer.enabled?
if @writer
@writer.enable
else