[Sheepdog] [PATCH] sheep: fix epoll_wait infinite loop

Yunkai Zhang yunkai.me at gmail.com
Wed Apr 25 11:23:58 CEST 2012


From: Yunkai Zhang <qiushu.zyk at taobao.com>

Add code to handle EPOLLERR and EPOLLHUP events in client_handler,
otherwise epoll_wait would run into infinite loop when these events
occur.

Signed-off-by: Yunkai Zhang <qiushu.zyk at taobao.com>
---
 sheep/sdnet.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/sheep/sdnet.c b/sheep/sdnet.c
index 74d42f9..408e7aa 100644
--- a/sheep/sdnet.c
+++ b/sheep/sdnet.c
@@ -613,7 +613,8 @@ static void client_handler(int fd, int events, void *data)
 	if (events & EPOLLOUT)
 		client_tx_handler(ci);
 
-	if (is_conn_dead(&ci->conn)) {
+	if ((events & (EPOLLERR | EPOLLHUP))
+		|| is_conn_dead(&ci->conn)) {
 		if (!(ci->conn.events & EPOLLIN))
 			list_del(&ci->conn.blocking_siblings);
 
-- 
1.7.7.6




More information about the sheepdog mailing list