summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/event-epoll.c6
-rw-r--r--libglusterfs/src/event-poll.c5
-rw-r--r--libglusterfs/src/event.c7
-rw-r--r--libglusterfs/src/event.h1
4 files changed, 18 insertions, 1 deletions
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
diff --git a/libglusterfs/src/event-poll.c b/libglusterfs/src/event-poll.c
index 09e9ce4c9ff..815e936548a 100644
--- a/libglusterfs/src/event-poll.c
+++ b/libglusterfs/src/event-poll.c
@@ -493,6 +493,11 @@ 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 da5704bc0ea..ce976f11d50 100644
--- a/libglusterfs/src/event.c
+++ b/libglusterfs/src/event.c
@@ -121,7 +121,14 @@ event_dispatch (struct event_pool *event_pool)
GF_VALIDATE_OR_GOTO ("event", event_pool, out);
ret = event_pool->ops->event_dispatch (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 b01ef24bb8e..8253034680c 100644
--- a/libglusterfs/src/event.h
+++ b/libglusterfs/src/event.h
@@ -57,6 +57,7 @@ struct event_pool {
* and live status */
int destroy;
int activethreadcount;
+ char dispatched; /* Is set if event_dispatch was called */
};
struct event_ops {