[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] cluster/rgmanager src/daemons/rg_locks.c src/d ...



CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL5
Changes by:	lhh sourceware org	2006-12-18 21:48:48

Modified files:
	rgmanager/src/daemons: rg_locks.c groups.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/rg_locks.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.7&r2=1.7.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/groups.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.25&r2=1.25.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/include/rg_locks.h.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.2&r2=1.2.2.1

--- 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:48:48	1.7.2.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/src/daemons/groups.c	2006/10/23 22:47:01	1.25
+++ cluster/rgmanager/src/daemons/groups.c	2006/12/18 21:48:48	1.25.2.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/include/rg_locks.h	2006/06/02 17:37:10	1.2
+++ cluster/rgmanager/include/rg_locks.h	2006/12/18 21:48:48	1.2.2.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);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]