public inbox for cluster-cvs@sourceware.org help / color / mirror / Atom feed
From: Lon Hohberger <lon@fedoraproject.org> To: cluster-cvs-relay@redhat.com Subject: cluster: RHEL47 - rgmanager: Make clustat and clusvcadm work faster Date: Mon, 20 Apr 2009 14:03:00 -0000 [thread overview] Message-ID: <20090420140248.79198120269@lists.fedorahosted.org> (raw) 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); }
reply other threads:[~2009-04-20 14:03 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20090420140248.79198120269@lists.fedorahosted.org \ --to=lon@fedoraproject.org \ --cc=cluster-cvs-relay@redhat.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).