[sheepdog] [PATCH v2] lib/sheep: handle multi-requests in one eventfd_read

Yu Yang yuyanggg at gmail.com
Wed May 27 07:56:04 CEST 2015


From: Yu Yang <yuyang at cmss.chinamobile.com>

When there are more than one request in eventfd, we
need to handle them one by one.

Signed-off-by: Yu Yang <yuyang at cmss.chinamobile.com>
---
 lib/shared/sheep.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/shared/sheep.c b/lib/shared/sheep.c
index 933be07..69b99dd 100644
--- a/lib/shared/sheep.c
+++ b/lib/shared/sheep.c
@@ -478,7 +478,9 @@ static void *reply_handler(void *data)
 	       !list_empty(&c->inflight_list)) {
 		bool empty;
 
-		eventfd_xread(c->reply_fd);
+		uint64_t events;
+		events = eventfd_xread(c->reply_fd);
+
 		sd_read_lock(&c->inflight_lock);
 		empty = list_empty(&c->inflight_list);
 		sd_rw_unlock(&c->inflight_lock);
@@ -486,7 +488,8 @@ static void *reply_handler(void *data)
 		if (empty)
 			continue;
 
-		sheep_handle_reply(c);
+		for (uint64_t i = 0; i < events; i++)
+			sheep_handle_reply(c);
 
 	}
 	pthread_detach(pthread_self());
-- 
1.7.9.5



More information about the sheepdog mailing list