Permalink
Browse files

Fix: EventMachine::Connection#get_peername can returns nil.

  • Loading branch information...
deni64k committed Jan 9, 2013
1 parent 56e81a1 commit 28c84349661f0516821cfe8cedf938969589b41e
Showing with 10 additions and 5 deletions.
  1. +10 −5 lib/yup/request_handler.rb
View
@@ -50,16 +50,21 @@ def on_message_complete
private
def send_answer
+ @logger.info {
+ peername = get_peername
+ port, ip = if peername
+ Socket.unpack_sockaddr_in(peername)
+ else
+ ["unknown", "unknown"]
+ end
+ "Sending the answer #{@status_code} to a client #{ip}:#{port}"
+ }
+
resp = WEBrick::HTTPResponse.new(:HTTPVersion => '1.1')
resp.status = @status_code
resp['Server'] = 'yupd'
send_data resp.to_s
close_connection_after_writing
-
- @logger.info {
- port, ip = Socket.unpack_sockaddr_in(get_peername)
- "Sent the answer #{@status_code} to a client #{ip}:#{port}"
- }
end
def shedule_request

0 comments on commit 28c8434

Please sign in to comment.