1 # -*- encoding: binary -*-
5 # if we get any error, try to write something back to the client
6 # assuming we haven't closed the socket, but don't get hung up
7 # if the socket is already closed or broken. We'll always ensure
8 # the socket is closed at the end of this function
11 if io.respond_to?(:kgio_trywrite)
14 io.write_nonblock(msg)
21 Rainbows.server.logger.error "app error: #{e.inspect}"
22 Rainbows.server.logger.error e.backtrace.join("\n")
26 def self.listen_loop(e)
27 Rainbows.alive or return
28 Rainbows.server.logger.error "listen loop error: #{e.inspect}."
29 Rainbows.server.logger.error e.backtrace.join("\n")
35 when EOFError, Errno::ECONNRESET, Errno::EPIPE, Errno::EINVAL,
36 Errno::EBADF, Errno::ENOTCONN
37 # swallow error if client shuts down one end or disconnects
38 when Unicorn::HttpParserError
39 Rainbows::Const::ERROR_400_RESPONSE # try to tell the client they're bad
40 when IOError # HttpParserError is an IOError
43 Rainbows::Const::ERROR_500_RESPONSE