cluster: RHEL47 - rgmanager: Make clustat and clusvcadm work faster

Lon Hohberger lon@fedoraproject.org
Mon Apr 20 14:03:00 GMT 2009


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=2dd6dabff89be06096d60a8f2400bbec9f351e98
Commit:        2dd6dabff89be06096d60a8f2400bbec9f351e98
Parent:        a1e8fd9d5db5f6a7c620d59a3e98752058785320
Author:        Lon Hohberger <lhh@redhat.com>
AuthorDate:    Thu Sep 11 12:51:19 2008 -0400
Committer:     Lon Hohberger <lhh@redhat.com>
CommitterDate: Mon Apr 20 10:01:26 2009 -0400

rgmanager: Make clustat and clusvcadm work faster

rhbz#461956
---
 rgmanager/src/daemons/rg_event.c |   34 +++++++++++++++++++++++++---------
 1 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/rgmanager/src/daemons/rg_event.c b/rgmanager/src/daemons/rg_event.c
index 48d0fca..335d6d2 100644
--- a/rgmanager/src/daemons/rg_event.c
+++ b/rgmanager/src/daemons/rg_event.c
@@ -27,6 +27,7 @@
 #include <magma.h>
 #include <magmamsg.h>
 #include <vf.h>
+#include <time.h>
 
 
 /**
@@ -40,6 +41,7 @@ static pthread_mutex_t mi_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
 static pthread_mutex_t event_queue_mutex = PTHREAD_MUTEX_INITIALIZER;
 static pthread_mutex_t mi_mutex = PTHREAD_MUTEX_INITIALIZER;
 #endif
+static pthread_cond_t event_queue_cond = PTHREAD_COND_INITIALIZER;
 static pthread_t event_thread = 0;
 static int transition_throttling = 5;
 static int central_events = 0;
@@ -321,23 +323,35 @@ void *
 _event_thread_f(void *arg)
 {
 	event_t *ev;
+	struct timeval now;
+	struct timespec expire;
 	int count = 0;
 
+	/* Event thread usually doesn't hang around.  When it's
+   	   spawned, sleep for this many seconds in order to let
+   	   some events queue up */
+	if (transition_throttling && !central_events) {
+		sleep(transition_throttling);
+	}
+
 	while (1) {
 		pthread_mutex_lock(&event_queue_mutex);
 		ev = event_queue;
-		if (ev)
-			list_remove(&event_queue, ev);
-		else
+		if (!ev && !central_events) {
+			gettimeofday(&now, NULL);
+			expire.tv_sec = now.tv_sec + 5;
+			expire.tv_nsec = now.tv_usec * 1000;
+			pthread_cond_timedwait(&event_queue_cond,
+						&event_queue_mutex,
+						&expire);
+			ev = event_queue;
+		}
+		if (!ev)
 			break; /* We're outta here */
 
-		++count;
-		/* Event thread usually doesn't hang around.  When it's
-	   	   spawned, sleep for this many seconds in order to let
-	   	   some events queue up */
-		if ((count==1) && transition_throttling && !central_events)
-			sleep(transition_throttling);
+		list_remove(&event_queue, ev);
 
+		++count;
 		pthread_mutex_unlock(&event_queue_mutex);
 
 		if (ev->ev_type == EVENT_CONFIG) {
@@ -417,6 +431,8 @@ insert_event(event_t *ev)
 
 		pthread_create(&event_thread, &attrs, _event_thread_f, NULL);
         	pthread_attr_destroy(&attrs);
+	} else {
+		pthread_cond_broadcast(&event_queue_cond);
 	}
 	pthread_mutex_unlock (&event_queue_mutex);
 }



More information about the Cluster-cvs mailing list