Skip to contentSkip to conversation

cluster/rgmanager ChangeLog include/rg_locks.h ...

Cluster-devel [email protected] 1 participant 1 message Jan 28, 2008

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/cluster
Module name: cluster
Branch: RHEL4
Changes by: lhh at sourceware.org 2008-01-28 19:27:20

Modified files:
rgmanager : ChangeLog
rgmanager/include: rg_locks.h rgmanager/src/daemons: groups.c main.c rg_locks.c rgmanager/src/utils: clulog.c

Log message:
Fix #430538 - unbounded status/clustat thread counts cause timeout errors

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/ChangeLog.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.5.2.34&r2=1.5.2.35
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/include/rg_locks.h.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.1.2.1&r2=1.1.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/groups.c.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.8.2.22&r2=1.8.2.23
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/main.c.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.9.2.23&r2=1.9.2.24
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/rg_locks.c.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.4.2.3&r2=1.4.2.4
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/utils/clulog.c.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.1.2.3&r2=1.1.2.4

rgmanager/ChangeLog +7 -0
@@ -1,3 +1,10 @@
+2008-01-28 Lon Hohberger <[email protected]>
+	* include/rg_locks.h, src/daemons/groups.c, rg_locks.c:
+	fix #430538 - unbounded status / clustat thread counts cause
+	timeout errors
+	* src/daemons/main.c, src/utils/clulog.c: Incorrect ccs API 
+	return code processing results in unwanted log messages
+
 2007-10-26 Lon Hohberger <[email protected]>
 	* src/daemons/main.c, src/utils/clustat.c, clusvcadm.c: Call
 	msg_set_nodeid() to ensure we route from the right IP on a 
rgmanager/include/rg_locks.h +21 -0
@@ -1,3 +1,20 @@
+/*
+  Copyright Red Hat, Inc. 2004-2007
+
+  This program is free software; you can redistribute it and/or modify it
+  under the terms of the GNU General Public License version 2 as published
+  by the Free Software Foundation.
+
+  This program is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; see the file COPYING.  If not, write to the
+  Free Software Foundation, Inc.,  675 Mass Ave, Cambridge, 
+  MA 02139, USA.
+*/
 #ifndef __RG_LOCKS_H
 #define __RG_LOCKS_H
 
@@ -20,6 +37,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);
 
rgmanager/src/daemons/groups.c +24 -2
@@ -43,6 +43,7 @@
 
 pthread_mutex_t config_mutex = PTHREAD_MUTEX_INITIALIZER;
 pthread_rwlock_t resource_lock = PTHREAD_RWLOCK_INITIALIZER;
+pthread_mutex_t status_mutex = PTHREAD_MUTEX_INITIALIZER;
 
 
 struct status_arg {
@@ -750,6 +751,14 @@
 
 	free(arg);
 
+	/* See if we have a slot... */
+	if (rg_inc_status() < 0) {
+		/* Too many outstanding status checks.  try again later. */
+		msg_send_simple(fd, RG_FAIL, RG_EAGAIN, 0);
+		msg_close(fd);
+		pthread_exit(NULL);
+	}
+
 	pthread_rwlock_rdlock(&resource_lock);
 
 	list_do(&_resources, res) {
@@ -768,8 +777,10 @@
 	msg_receive_timeout(fd, &hdr, sizeof(hdr), 10);
 
 	msg_close(fd);
+	
+	rg_dec_status();
 
-	return NULL;
+	pthread_exit(NULL);
 }
 
 
@@ -887,6 +898,10 @@
 	char *name;
 	rg_state_t svcblk;
 
+	/* Only one status thread@a time, please! */
+	if (pthread_mutex_trylock(&status_mutex) != 0)
+		pthread_exit(NULL);
+
 	pthread_rwlock_rdlock(&resource_lock);
 	list_do(&_tree, curr) {
 
@@ -911,8 +926,9 @@
 	} while (!list_done(&_tree, curr));
 
 	pthread_rwlock_unlock(&resource_lock);
+	pthread_mutex_unlock(&status_mutex);
 
-	return NULL;
+	pthread_exit(NULL);
 }
 
 
@@ -1164,6 +1180,12 @@
 		pthread_mutex_unlock(&config_mutex);
 	}
 
+	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... */
 	if (load_resources(fd, &reslist, &rulelist) != 0) {
rgmanager/src/daemons/main.c +2 -2
@@ -653,10 +653,10 @@
 	char *v;
 	char internal = 0;
 
-	if (ccsfd == -1) {
+	if (ccsfd < 0) {
 		internal = 1;
 		ccsfd = ccs_connect();
-		if (ccsfd == -1)
+		if (ccsfd < 0)
 			return -1;
 	}
 
rgmanager/src/daemons/rg_locks.c +52 -2

73 lines not on this page · raw message

rgmanager/src/utils/clulog.c +2 -2
@@ -54,10 +54,10 @@
 	char *v;
 	char internal = 0;
 
-	if (ccsfd == -1) {
+	if (ccsfd < 0) {
 		internal = 1;
 		ccsfd = ccs_connect();
-		if (ccsfd == -1)
+		if (ccsfd < 0)
 			return -1;
 	}