[Cluster-devel] cluster/rgmanager/src clulib/alloc.c daemons/g ...

lhh at sourceware.org lhh at sourceware.org
Wed Feb 21 20:49:17 UTC 2007


CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	lhh at sourceware.org	2007-02-21 20:49:17

Modified files:
	rgmanager/src/clulib: alloc.c 
	rgmanager/src/daemons: groups.c 

Log message:
	Resolves: 222445
	* Only let one status queue thread spawn at a time
	
	Other:
	* Misc tweaks to alloc.c for debugging

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/clulib/alloc.c.diff?cvsroot=cluster&r1=1.9&r2=1.10
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/groups.c.diff?cvsroot=cluster&r1=1.26&r2=1.27

--- cluster/rgmanager/src/clulib/alloc.c	2006/08/07 22:05:01	1.9
+++ cluster/rgmanager/src/clulib/alloc.c	2007/02/21 20:49:16	1.10
@@ -128,8 +128,8 @@
 				   for instance) */
 #undef  AGGR_RECLAIM		/* consolidate_all on free (*slow*) */
 
-#undef  STACKSIZE	/*4	   backtrace to store if DEBUG is set */
-//#define STACKSIZE 4
+//#undef  STACKSIZE	/*4	   backtrace to store if DEBUG is set */
+#define STACKSIZE 1		/* at least 1 gets you free addr */
 
 #undef	GDB_HOOK		/* Dump program addresses in malloc_table
 				   using a fork/exec of gdb (SLOW but fun)
@@ -806,6 +806,10 @@
 free(void *p)
 {
 	memblock_t *b;
+#ifdef STACKSIZE
+	void *pc = __builtin_return_address(0);
+	int x;
+#endif
 
 	if (!p) {
 #if 0
@@ -826,16 +830,6 @@
 		die_or_return();
 	}
 
-#ifdef PARANOID
-	/* Remove from the allocated list if we're tracking it. */
-	if (!remove_alloc_block(b)) {
-		fprintf(stderr, "free(%p) @ %p - Not allocated\n",
-			p, __builtin_return_address(0));
-		pthread_mutex_unlock(&_alloc_mutex);
-		die_or_return();
-	}
-#endif
-
 	if (!is_valid_alloc(b)) {
 #ifdef DEBUG
 		if (!is_valid_free(b))
@@ -843,14 +837,37 @@
 				"free(%p) @ %p - Invalid address\n",
 				p, __builtin_return_address(0));
 		else
+#ifdef STACKSIZE
+			fprintf(stderr,
+				"free(%p) @ %p - Already free @ %p\n",
+				p, __builtin_return_address(0), b->mb_pc[0]);
+#else
 			fprintf(stderr,
 				"free(%p) @ %p - Already free\n",
 				p, __builtin_return_address(0));
 #endif
+
+#endif
 		pthread_mutex_unlock(&_alloc_mutex);
 		die_or_return();
 	}
 
+#ifdef PARANOID
+	/* Remove from the allocated list if we're tracking it. */
+	if (!remove_alloc_block(b)) {
+		fprintf(stderr, "free(%p) @ %p - Not allocated\n",
+			p, __builtin_return_address(0));
+		pthread_mutex_unlock(&_alloc_mutex);
+		die_or_return();
+	}
+#endif
+
+#ifdef STACKSIZE
+	for (x = 0; x < STACKSIZE; x++)
+		b->mb_pc[x] = NULL;
+	b->mb_pc[0] = pc;
+#endif
+
 	b->mb_state = ST_FREE;
 	b->mb_next = NULL;
 
--- cluster/rgmanager/src/daemons/groups.c	2006/12/18 21:55:27	1.26
+++ cluster/rgmanager/src/daemons/groups.c	2007/02/21 20:49:17	1.27
@@ -44,6 +44,7 @@
 static fod_t *_domains = NULL;
 
 pthread_mutex_t config_mutex = PTHREAD_MUTEX_INITIALIZER;
+pthread_mutex_t status_mutex = PTHREAD_MUTEX_INITIALIZER;
 pthread_rwlock_t resource_lock = PTHREAD_RWLOCK_INITIALIZER;
 
 void res_build_name(char *, size_t, resource_t *);
@@ -991,6 +992,10 @@
 	resource_node_t *curr;
 	rg_state_t svcblk;
 	char rg[64];
+	
+	/* Only one status thread at a time, please! */
+	if (pthread_mutex_trylock(&status_mutex) != 0)
+		return NULL;
 
 	pthread_rwlock_rdlock(&resource_lock);
 	list_do(&_tree, curr) {
@@ -1013,6 +1018,7 @@
 	} while (!list_done(&_tree, curr));
 
 	pthread_rwlock_unlock(&resource_lock);
+	pthread_mutex_unlock(&status_mutex);
 
 	return NULL;
 }




More information about the Cluster-devel mailing list