Skip to content

Commit

Permalink
use read nonblock on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
gnufied committed Jul 22, 2008
1 parent 053ccb6 commit aef42b4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/packet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@
PACKET_APP = File.expand_path'../' unless defined?(PACKET_APP)

module Packet
VERSION='0.1.8'
VERSION='0.1.9'
end
12 changes: 9 additions & 3 deletions lib/packet/packet_nbio.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@ def gen_worker_key(worker_name,worker_key = nil)
def read_data(t_sock)
sock_data = []
begin
while(t_data = t_sock.recv_nonblock((16*1024)-1))
raise DisconnectError.new(t_sock,sock_data.join) if t_data.empty?
sock_data << t_data
if RUBY_PLATFORM =~ /linux/i
while(t_data = t_sock.read_nonblock((16*1024)-1))
sock_data << t_data
end
else
while(t_data = t_sock.recv_nonblock((16*1024)-1))
raise DisconnectError.new(t_sock,sock_data.join) if t_data.empty?
sock_data << t_data
end
end
rescue Errno::EAGAIN
return sock_data.join
Expand Down

0 comments on commit aef42b4

Please sign in to comment.