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 clulib/alloc.c daemons/g ...
Date: 21 Feb 2007 20:49:17 -0000	[thread overview]
Message-ID: <20070221204917.20601.qmail@sourceware.org> (raw)

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;
 }



                 reply	other threads:[~2007-02-21 20:49 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=20070221204917.20601.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.