From d80537d8e588da57db609332c2d89873e0a368ca Mon Sep 17 00:00:00 2001 From: Krishnan Parthasarathi Date: Thu, 13 Aug 2015 14:39:58 +0530 Subject: event: add dispatched flag to know if event_dispatch was called This is important for glusterfs processes that choose to reconfigure no. of event-threads (a.k.a epoll worker-threads) before they call event_dispatch on the event_pool. glusterd needs this today. Change-Id: Ia8df3c958545324472262c555ed84b71797f002e BUG: 1242421 Signed-off-by: Krishnan Parthasarathi Reviewed-on: http://review.gluster.org/11911 Tested-by: NetBSD Build System Reviewed-by: Niels de Vos Tested-by: Gluster Build System --- libglusterfs/src/event-epoll.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'libglusterfs/src/event-epoll.c') diff --git a/libglusterfs/src/event-epoll.c b/libglusterfs/src/event-epoll.c index 154bb1b2a27..dfa97cad368 100644 --- a/libglusterfs/src/event-epoll.c +++ b/libglusterfs/src/event-epoll.c @@ -791,7 +791,11 @@ event_reconfigure_threads_epoll (struct event_pool *event_pool, int value) oldthreadcount = event_pool->eventthreadcount; - if (oldthreadcount < value) { + /* Start 'worker' threads as necessary only if event_dispatch() + * was called before. If event_dispatch() was not called, there + * will be no epoll 'worker' threads running yet. */ + + if (event_pool->dispatched && oldthreadcount < value) { /* create more poll threads */ for (i = oldthreadcount; i < value; i++) { /* Start a thread if the index at this location -- cgit