This is the mail archive of the cluster-cvs@sourceware.org mailing list for the cluster.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RHEL5 - rgmanager: Make clustat and clusvcadm work faster


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=50dc172c12f728ebb5916e2059b01404d94dd066
Commit:        50dc172c12f728ebb5916e2059b01404d94dd066
Parent:        1cc68885904a1e393e2dcd6d788ae5099ef7124d
Author:        Lon Hohberger <lhh@redhat.com>
AuthorDate:    Thu Sep 11 13:08:51 2008 -0400
Committer:     Lon Hohberger <lhh@redhat.com>
CommitterDate: Mon Sep 15 16:58:55 2008 -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 08137de..d2c7cd3 100644
--- a/rgmanager/src/daemons/rg_event.c
+++ b/rgmanager/src/daemons/rg_event.c
@@ -27,6 +27,7 @@
 #include <stdint.h>
 #include <vf.h>
 #include <members.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;
@@ -390,23 +392,35 @@ void *
 _event_thread_f(void __attribute__ ((unused)) *arg)
 {
 	event_t *ev;
+	struct timeval now;
+	struct timespec expire;
 	int notice = 0, 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) {
@@ -506,6 +520,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);
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]