Skip to content

Commit

Permalink
Bump version, minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sutto committed Jan 2, 2010
1 parent 984aaee commit 2f23adf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/perennial.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

module Perennial

VERSION = [1, 2, 3]
VERSION = [1, 2, 4]

has_library :dispatchable, :hookable, :loader, :logger, :nash,
:loggable, :manifest, :settings, :argument_parser,
Expand Down
10 changes: 6 additions & 4 deletions lib/perennial/protocols/pure_ruby/json_transport.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,18 @@ def write_message(action, payload = {}, &callback)
"payload" => payload,
"sent-at" => Time.now
}.merge(callback_options(callback))) + SEPERATOR
with_socket { |s| s.write(message) }
with_socket do |s|
raise NoConnection, "no connection the server at #{@host}:#{@port}" if s.nil?
s.write(message)
end
end

def read_message
def read_message(timeout = nil)
with_socket do |s|
raise NoConnection, "no connection the server at #{@host}:#{@port}" if s.nil?
message = nil
begin
Perennial::TimerImplementation.timeout(timeout) do
Perennial::TimerImplementation.timeout(timeout || @timeout) do
message = JSON.parse(s.gets.strip)
end
rescue Timeout::Error
Expand Down Expand Up @@ -118,7 +121,6 @@ def socket
@socket.setsockopt Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1
@retry = nil
rescue SocketError, SystemCallError, IOError, Timeout::Error => err
# TODO: Raise a connection error here
dead!
end
@socket
Expand Down

0 comments on commit 2f23adf

Please sign in to comment.