diff options
author | Krishnan Parthasarathi <kparthas@redhat.com> | 2015-08-28 14:27:20 +0530 |
---|---|---|
committer | Shyamsundar Ranganathan <srangana@redhat.com> | 2015-08-28 10:14:01 -0700 |
commit | dedf2bde88020adbabb80204830878f060fa614c (patch) | |
tree | b80e95e397e8fb2e396bfaa1bd8d7406d2c10171 | |
parent | bd9dd34700de63f96b9fc65125d539b2c16fa6bf (diff) |
event-epoll: Use pollers[] to check if event_pool_dispatch was called
BUG: 1242421
Change-Id: I1a0044653f15d33f89ffe16edc5baba40393dec3
Signed-off-by: Krishnan Parthasarathi <kparthas@redhat.com>
Reviewed-on: http://review.gluster.org/12004
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
Reviewed-by: Raghavendra Talur <rtalur@redhat.com>
-rw-r--r-- | libglusterfs/src/event-epoll.c | 20 | ||||
-rw-r--r-- | libglusterfs/src/event-poll.c | 4 | ||||
-rw-r--r-- | libglusterfs/src/event.c | 4 | ||||
-rw-r--r-- | libglusterfs/src/event.h | 1 |
4 files changed, 19 insertions, 10 deletions
diff --git a/libglusterfs/src/event-epoll.c b/libglusterfs/src/event-epoll.c index dfa97cad368..78eff9398a6 100644 --- a/libglusterfs/src/event-epoll.c +++ b/libglusterfs/src/event-epoll.c @@ -765,6 +765,23 @@ event_dispatch_epoll (struct event_pool *event_pool) return ret; } +/** + * @param event_pool event_pool on which fds of interest are registered for + * events. + * + * @return 1 if at least one epoll worker thread is spawned, 0 otherwise + * + * NB This function SHOULD be called under event_pool->mutex. + */ + +static int +event_pool_dispatched_unlocked (struct event_pool *event_pool) +{ + return (event_pool->pollers[0] != 0); + +} + + int event_reconfigure_threads_epoll (struct event_pool *event_pool, int value) { @@ -795,7 +812,8 @@ event_reconfigure_threads_epoll (struct event_pool *event_pool, int value) * was called before. If event_dispatch() was not called, there * will be no epoll 'worker' threads running yet. */ - if (event_pool->dispatched && oldthreadcount < value) { + if (event_pool_dispatched_unlocked(event_pool) + && (oldthreadcount < value)) { /* create more poll threads */ for (i = oldthreadcount; i < value; i++) { /* Start a thread if the index at this location diff --git a/libglusterfs/src/event-poll.c b/libglusterfs/src/event-poll.c index 815e936548a..51c0cf1f4e7 100644 --- a/libglusterfs/src/event-poll.c +++ b/libglusterfs/src/event-poll.c @@ -493,10 +493,6 @@ int event_reconfigure_threads_poll (struct event_pool *event_pool, int value) { /* No-op for poll */ - /* One could check event_pool->dispatched before creating threads when - * multi-threaded poll based support is implemented. - * event_pool->dispatch indicates if event_dispatch was called. - * */ return 0; } diff --git a/libglusterfs/src/event.c b/libglusterfs/src/event.c index ce976f11d50..75b73059112 100644 --- a/libglusterfs/src/event.c +++ b/libglusterfs/src/event.c @@ -124,10 +124,6 @@ event_dispatch (struct event_pool *event_pool) if (ret) goto out; - pthread_mutex_lock (&event_pool->mutex); - { - event_pool->dispatched = 1; - } pthread_mutex_unlock (&event_pool->mutex); out: return ret; diff --git a/libglusterfs/src/event.h b/libglusterfs/src/event.h index 8253034680c..b01ef24bb8e 100644 --- a/libglusterfs/src/event.h +++ b/libglusterfs/src/event.h @@ -57,7 +57,6 @@ struct event_pool { * and live status */ int destroy; int activethreadcount; - char dispatched; /* Is set if event_dispatch was called */ }; struct event_ops { |