diff options
-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 { |