This repository has been archived by the owner on Dec 7, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 93
Nonblock without exception #166
Open
HoneyryderChuck
wants to merge
14
commits into
celluloid:master
Choose a base branch
from
HoneyryderChuck:nonblock_without_exception
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
21ddab6
adding RSpec namespace (3.4.0) doesn't contain the global space monke…
5321f59
using the new read_ and write_nonblock signature (ruby 2.1) in which …
8098ebc
Merge branch 'master' of https://github.com/celluloid/celluloid-io in…
de71524
adapted the code from the http gem according to tarcieri's suggestion…
f4160d6
moving the #perform_io to the socket base class, so that udp can use it
ecdd882
encapsulating nonblock usage for UDPSockets within the #perform_io me…
13630b7
adding exception: false option to the nonblocking APIs, except UDPSoc…
d21ac9c
adding the exception: false option when using the udp socket to perfo…
b397086
defining #recvfrom method in UDPSocket according to ruby version
d621577
redefining #read* and write_nonblock for ruby 2.1 or bigger; passing …
f68e551
adding WaitReadable condition to spec only when ruby under 2.1
c85cac9
use Timeout.timeout, ruby 2.3 is deprecating Kernel.timeout
1e8b3d6
making nonblock calls within celluloid streams exceptionless by defau…
339b771
Merge branch 'master' into nonblock_without_exception
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,12 +38,13 @@ def sysread(length = nil, buffer = nil) | |
buffer ||= ''.force_encoding(Encoding::ASCII_8BIT) | ||
|
||
@read_latch.synchronize do | ||
begin | ||
read_nonblock(length, buffer) | ||
rescue ::IO::WaitReadable | ||
wait_readable | ||
retry | ||
op = perform_io do | ||
# TODO: remove after ending ruby 2.0.0 support | ||
RUBY_VERSION < "2.1" ? | ||
read_nonblock(length, buffer) : | ||
read_nonblock(length, buffer, exception: false) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The formatting here is just ugly... |
||
end | ||
raise EOFError if op == :eof | ||
end | ||
|
||
buffer | ||
|
@@ -58,17 +59,13 @@ def syswrite(string) | |
|
||
@write_latch.synchronize do | ||
while total_written < length | ||
begin | ||
written = write_nonblock(remaining) | ||
rescue ::IO::WaitWritable | ||
wait_writable | ||
retry | ||
rescue EOFError | ||
return total_written | ||
rescue Errno::EAGAIN | ||
wait_writable | ||
retry | ||
end | ||
written = perform_io do | ||
# TODO: remove after ending ruby 2.0.0 support | ||
RUBY_VERSION < "2.1" ? | ||
write_nonblock(remaining) : | ||
write_nonblock(remaining, exception: false) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto... |
||
end | ||
return total_written if written == :eof | ||
|
||
total_written += written | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, this definitely seems like the wrong place to put this check. In the DNS resolver? It should be using a
Celluloid::IO::UDPSocket
, and these details should be pushed down there.