more uninitialized mutexes in rc.39

Christoph Badura bad at bsd.de
Mon Feb 26 18:59:40 EST 2007


Hey Carter,

I've found two more unintialized mutexes while playing around with racluster.

Having to add mutex initialization to new uses of ArgusHashTables is getting
old fast.  What do you thing about hiding the common code to allocate
a hash table behind a call to

int ArgusNewHashTable(struct ArgusHashTable *htable, int nelem. size_t elemsz)?

Usage would be like

if (ArgusnewHashTable(&retn->htable, RA_HASHTABLESIZE, sizeof (void *)) != 0)
	ArgusLog (LOG_ERR, "ArgusNewAggregator: ArgusCalloc error %s", strerror(errno));

to replace a randomly picked call common/argus_client.c.

Meanwhile, attached are my patches to initialize the mutexes NetBSD's libpthread
complains about.

--chris

--- common/argus_parser.c.orig	2006-11-10 17:34:49.000000000 +0100
+++ common/argus_parser.c
@@ -119,4 +119,8 @@ ArgusInitializeParser(struct ArgusParser
    parser->RaLabelCounter      = 0;
 
    gettimeofday(&parser->ArgusRealTime, 0L);
+
+#if defined(ARGUS_THREADS)
+   pthread_mutex_init(&parser->lock, NULL);
+#endif
 }

--- common/argus_client.c.orig	2007-01-26 22:24:34.000000000 +0100
+++ common/argus_client.c
@@ -7241,6 +7241,10 @@ ArgusNewAggregator (struct ArgusParserSt
 
    retn->htable.size = RA_HASHTABLESIZE;
 
+#if defined(ARGUS_THREADS)
+   pthread_mutex_init(&retn->htable.lock, NULL);
+#endif
+
    retn->RaMetricFetchAlgorithm = ArgusFetchDuration;
 
    return (retn);



More information about the argus mailing list