Commit 246e83eb by Nala Ginrut

close the connection gracefully

parent 2c52519e
......@@ -42,10 +42,12 @@
;; So, Artanis isn't compatible with Linux 2.6.9 and before.
(epoll-ctl epfd EPOLL_CTL_DEL conn-fd #f) ; #f means %null-pointer here
;; Close the connection gracefully
;; NOTE: `shutdown' is preferred here, for `close' may cause half-connections
;; and the work-table will get wrong result.
;; Stop both recv and trans
(when (not (port-closed? conn)) (shutdown conn 2))))
;; NOTE: `shutdown' is preferred here to stop receiving data.
;; Then try to send all the rest data.
;; NOTE: We can't just close it here, if we do so, then we've lost the information
;; to get fd from port which is the key to remove task from work-table.
(shutdown conn 1)
(force-output conn)))
;; NOTE: Close operation must follow these steps:
;; 1. remove fd from epoll event
......
......@@ -256,7 +256,8 @@
(::define (remove-from-work-table! wt client)
(:anno: (work-table ragnarok-client) -> ANY)
(DEBUG "Removed task ~a~%" (client-sockport client))
(hashv-remove! (work-table-content wt) (client-sockport-decriptor client)))
(hashv-remove! (work-table-content wt) (client-sockport-decriptor client))
(close (client-sockport client)))
;; work-table -> ragnarok-client -> task -> ANY
(::define (add-a-task-to-work-table! wt client task)
......
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