Skip to content

Commit

Permalink
#78 Revert from read_nonblock back to recv_nonblock. Fix minor bug in…
Browse files Browse the repository at this point in the history
… template_stream_protocol.
  • Loading branch information
ryanmelt committed Mar 12, 2015
1 parent c523da8 commit 4d1cbe1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/cosmos/io/json_drb.rb
Expand Up @@ -194,7 +194,7 @@ def self.receive_message(socket, data)
def self.get_at_least_x_bytes_of_data(socket, current_data, required_num_bytes)
while (current_data.length < required_num_bytes)
begin
data = socket.read_nonblock(65535)
data = socket.recv_nonblock(65535)
if data.length == 0
current_data.replace('')
return
Expand Down
4 changes: 2 additions & 2 deletions lib/cosmos/streams/tcpip_socket_stream.rb
Expand Up @@ -49,7 +49,7 @@ def read
# No read mutex is needed because there is only one stream procesor
# reading
begin
data = @read_socket.read_nonblock(65535)
data = @read_socket.recv_nonblock(65535)
@raw_logger_pair.read_logger.write(data) if @raw_logger_pair
rescue IO::WaitReadable
# Wait for the socket to be ready for reading or for the timeout
Expand Down Expand Up @@ -79,7 +79,7 @@ def read_nonblock
# No read mutex is needed because there is only one stream procesor
# reading
begin
data = @read_socket.read_nonblock(65535)
data = @read_socket.recv_nonblock(65535)
@raw_logger_pair.read_logger.write(data) if @raw_logger_pair
rescue Errno::EAGAIN, Errno::EWOULDBLOCK, Errno::ECONNRESET, Errno::ECONNABORTED
data = ''
Expand Down
2 changes: 1 addition & 1 deletion lib/cosmos/streams/template_stream_protocol.rb
Expand Up @@ -126,7 +126,7 @@ def post_write_data(packet, data)
# Scan the response for the variables in brackets <VARIABLE>
# Write the packet value with each of the values received
response_values = response_string.scan(response_regexp)[0]
raise "Unexpected response received: #{response_string}" if response_values.length != response_item_names.length
raise "Unexpected response received: #{response_string}" if !response_values or (response_values.length != response_item_names.length)
response_values.each_with_index do |value, i|
result_packet.write(response_item_names[i], value)
end
Expand Down

0 comments on commit 4d1cbe1

Please sign in to comment.