Commit ef8c4ecd by Nala Ginrut

fixed: avoid crash while epoll-wait is timeout

parent 098090a9
......@@ -371,32 +371,32 @@
(when (not http)
(throw 'artanis-err 500 ragnarok-http-gateway-run
"BUG: There should be `http' protocol at least!"))
(let main-loop((client (get-one-request-from-clients http server)))
(let ((proto-name (detect-client-protocol client)))
(DEBUG "Enter main-loop, protocol is ~a~%" proto-name)
(call-with-sigint
;; handle C-c to break the server loop properly
(lambda ()
(DEBUG "Prepare to serve one request ~a~%" (client-sockport client))
(catch 'artanis-err
(catch 'artanis-err
(lambda ()
(let main-loop((client (get-one-request-from-clients http server)))
(let ((proto-name (detect-client-protocol client)))
(DEBUG "Enter main-loop, protocol is ~a~%" proto-name)
(call-with-sigint
;; handle C-c to break the server loop properly
(lambda ()
(DEBUG "Prepare to serve one request ~a~%" (client-sockport client))
(serve-one-request handler http server client)
(DEBUG "Serve one done~%"))
(lambda ()
(serve-one-request handler http server client))
(lambda e
(call-with-values
(lambda ()
(apply (make-unstop-exception-handler (exception-from-server)) e))
(lambda (r b s)
(ragnarok-write http server client r b #f)
(ragnarok-close http server client #f)))))
(DEBUG "Serve one done~%"))
(lambda ()
;; NOTE: The remote connection will be handled gracefully in ragnarok-close
;; NOTE: The parameters will be lost when exception raised here, so we can't
;; use any of current-task/server/client/proto in the exception handler
(DEBUG "Prepare to close connection ~a~%" (client-ip client))
(ragnarok-close http server client #f)))
(DEBUG "main-loop again~%")
(main-loop (get-one-request-from-clients http server))))))
;; NOTE: The remote connection will be handled gracefully in ragnarok-close
;; NOTE: The parameters will be lost when exception raised here, so we can't
;; use any of current-task/server/client/proto in the exception handler
(DEBUG "Prepare to close connection ~a~%" (client-ip client))
(ragnarok-close http server client #f)))
(DEBUG "main-loop again~%")
(main-loop (get-one-request-from-clients http server)))))
(lambda e
(call-with-values
(lambda ()
(apply (make-unstop-exception-handler (exception-from-server)) e))
(lambda (r b s)
(ragnarok-write http server client r b #f)
(ragnarok-close http server client #f)))))))
;; NOTE: we don't schedule guile-engine, although it provides naive mechanism for scheduling.
(define (new-guile-engine)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment