From: Yunkai Zhang <[email protected]>

When EPOLLERR/EPOLLHUP events occur,  other events(eg: EPOLLIN) may be
inclued at the same time, but we should priority to process them as the
connection was destroyed.

Signed-off-by: Yunkai Zhang <[email protected]>
---
 sheep/sdnet.c |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/sheep/sdnet.c b/sheep/sdnet.c
index 34d65cf..f69ec98 100644
--- a/sheep/sdnet.c
+++ b/sheep/sdnet.c
@@ -660,18 +660,21 @@ static void client_handler(int fd, int events, void *data)
 {
        struct client_info *ci = (struct client_info *)data;
 
+       if (events & (EPOLLERR | EPOLLHUP))
+           goto err;
+
        if (events & EPOLLIN)
                client_rx_handler(ci);
 
        if (events & EPOLLOUT)
                client_tx_handler(ci);
 
-       if ((events & (EPOLLERR | EPOLLHUP))
-               || is_conn_dead(&ci->conn)) {
+       if (is_conn_dead(&ci->conn)) {
                if (!(ci->conn.events & EPOLLIN))
                        list_del(&ci->conn.blocking_siblings);
-
-               dprintf("closed connection %d\n", fd);
+err:
+               dprintf("closed connection %d, %s:%d\n", fd,
+                       ci->conn.ipstr, ci->conn.port);
                unregister_event(fd);
                client_decref(ci);
        }
-- 
1.7.10.2

-- 
sheepdog mailing list
[email protected]
http://lists.wpkg.org/mailman/listinfo/sheepdog

Reply via email to