All of lore.kernel.org
 help / color / mirror / Atom feed
From: lhh@sourceware.org <lhh@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] cluster/rgmanager src/daemons/groups.c src/dae ...
Date: 18 Dec 2006 21:47:00 -0000	[thread overview]
Message-ID: <20061218214700.23217.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL50
Changes by:	lhh at sourceware.org	2006-12-18 21:46:58

Modified files:
	rgmanager/src/daemons: groups.c rg_locks.c 
	rgmanager/include: rg_locks.h 

Log message:
	Implement cap on max # of outstanding status check threads; fixes bugzilla #218697

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/groups.c.diff?cvsroot=cluster&only_with_tag=RHEL50&r1=1.25&r2=1.25.4.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/rg_locks.c.diff?cvsroot=cluster&only_with_tag=RHEL50&r1=1.7&r2=1.7.4.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/include/rg_locks.h.diff?cvsroot=cluster&only_with_tag=RHEL50&r1=1.2&r2=1.2.4.1

--- cluster/rgmanager/src/daemons/groups.c	2006/10/23 22:47:01	1.25
+++ cluster/rgmanager/src/daemons/groups.c	2006/12/18 21:46:57	1.25.4.1
@@ -1,5 +1,5 @@
 /*
-  Copyright Red Hat, Inc. 2002-2003
+  Copyright Red Hat, Inc. 2002-2006
   Copyright Mission Critical Linux, Inc. 2000
 
   This program is free software; you can redistribute it and/or modify it
@@ -849,6 +849,15 @@
 
 	free(arg);
 
+	/* See if we have a slot... */
+	if (rg_inc_status() < 0) {
+		/* Too many outstanding status checks.  try again later. */
+		msg_send_simple(ctx, RG_FAIL, RG_EAGAIN, 0);
+		msg_close(ctx);
+		msg_free_ctx(ctx);
+		return NULL;
+	}
+	
 	pthread_rwlock_rdlock(&resource_lock);
 
 	list_do(&_tree, node) {
@@ -866,6 +875,8 @@
 	msg_receive(ctx, &hdr, sizeof(hdr), 10);
 	msg_close(ctx);
 	msg_free_ctx(ctx);
+	
+	rg_dec_status();
 
 	return NULL;
 }
@@ -1245,6 +1256,12 @@
 		pthread_mutex_unlock(&config_mutex);
 		free(val);
 	}
+	
+	if (ccs_get(fd, "/cluster/rm/@statusmax", &val) == 0) {
+		if (strlen(val)) 
+			rg_set_statusmax(atoi(val));
+		free(val);
+	}
 
 	clulog(LOG_DEBUG, "Building Resource Trees\n");
 	/* About to update the entire resource tree... */
--- cluster/rgmanager/src/daemons/rg_locks.c	2006/06/02 17:37:10	1.7
+++ cluster/rgmanager/src/daemons/rg_locks.c	2006/12/18 21:46:58	1.7.4.1
@@ -33,6 +33,9 @@
 static int __rg_threadcnt = 0;
 static int __rg_initialized = 0;
 
+static int _rg_statuscnt = 0;
+static int _rg_statusmax = 5; /* XXX */
+
 static pthread_mutex_t locks_mutex = PTHREAD_MUTEX_INITIALIZER;
 static pthread_cond_t unlock_cond = PTHREAD_COND_INITIALIZER;
 static pthread_cond_t zero_cond = PTHREAD_COND_INITIALIZER;
@@ -264,6 +267,48 @@
 
 
 int
+rg_set_statusmax(int max)
+{
+	int old;
+	
+	if (max <= 3)
+		max = 3;
+	
+	pthread_mutex_lock(&locks_mutex);
+	old = _rg_statusmax;
+	_rg_statusmax = max;
+	pthread_mutex_unlock(&locks_mutex);
+	return old;
+}
+
+
+int
+rg_inc_status(void)
+{
+	pthread_mutex_lock(&locks_mutex);
+	if (_rg_statuscnt >= _rg_statusmax) {
+		pthread_mutex_unlock(&locks_mutex);
+		return -1;
+	}
+	++_rg_statuscnt;
+	pthread_mutex_unlock(&locks_mutex);
+	return 0;
+}
+
+
+int
+rg_dec_status(void)
+{
+	pthread_mutex_lock(&locks_mutex);
+	--_rg_statuscnt;
+	if (_rg_statuscnt < 0)
+		_rg_statuscnt = 0;
+	pthread_mutex_unlock(&locks_mutex);
+	return 0;
+}
+
+
+int
 rg_wait_threads(void)
 {
 	pthread_mutex_lock(&locks_mutex);
--- cluster/rgmanager/include/rg_locks.h	2006/06/02 17:37:10	1.2
+++ cluster/rgmanager/include/rg_locks.h	2006/12/18 21:46:58	1.2.4.1
@@ -20,6 +20,10 @@
 int rg_set_uninitialized(void);
 int rg_wait_initialized(void);
 
+int rg_inc_status(void);
+int rg_dec_status(void);
+int rg_set_statusmax(int max);
+
 int ccs_lock(void);
 int ccs_unlock(int fd);
 



                 reply	other threads:[~2006-12-18 21:47 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=20061218214700.23217.qmail@sourceware.org \
    --to=lhh@sourceware.org \
    /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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.