Hi Timothy:
On Fri, Apr 11, 2008 at 1:58 PM, Witham, Timothy D
<[EMAIL PROTECTED]> wrote:
> It breaks the /?filter=summary but that is easily fixed by including
> r1215:
>
> Index: server.c
> ===================================================================
> --- server.c (revision 1185)
> +++ server.c (revision 1215)
> @@ -121,13 +121,9 @@
> source->hosts_up, source->hosts_down);
> if (rc) return 1;
>
> - pthread_mutex_unlock(root.sum_finished);
> - if (source->ds) {
> - pthread_mutex_lock(source->sum_finished);
> - rc = hash_foreach(source->metric_summary, metric_summary, (void*)
> client);
> - pthread_mutex_unlock(source->sum_finished);
> - }
> - pthread_mutex_unlock(root.sum_finished);
> + pthread_mutex_lock(source->sum_finished);
> + rc = hash_foreach(source->metric_summary, metric_summary, (void*)
> client);
> + pthread_mutex_unlock(source->sum_finished);
>
> return rc;
> }
>
>
>
> If we add that, then I will vote for it since that is what I am running
> in production now. Thanks!
It looks like I missed revisions 1206 and 1215. I've updated the
patch. Please review again.
Thanks,
Bernard
Index: gmetad/process_xml.c
===================================================================
--- gmetad/process_xml.c (revision 1139)
+++ gmetad/process_xml.c (working copy)
@@ -216,7 +216,7 @@
source->ds = xmldata->ds;
/* Initialize the partial sum lock */
- source->sum_finished = (pthread_mutex_t*)
+ source->sum_finished = (pthread_mutex_t *)
malloc(sizeof(pthread_mutex_t));
pthread_mutex_init(source->sum_finished, NULL);
@@ -228,13 +228,14 @@
{ /* Found Cluster. Put into our Source buffer in xmldata. */
memcpy(source, hash_datum->data, hash_datum->size);
datum_free(hash_datum);
- source->hosts_up = 0;
- source->hosts_down = 0;
/* Grab the "partial sum" mutex until we are finished
* summarizing. Needs to be done asap.*/
pthread_mutex_lock(source->sum_finished);
+ source->hosts_up = 0;
+ source->hosts_down = 0;
+
hash_foreach(source->metric_summary, zero_out_summary, NULL);
}
@@ -332,7 +333,7 @@
source->ds = xmldata->ds;
/* Initialize the partial sum lock */
- source->sum_finished = (pthread_mutex_t*)
+ source->sum_finished = (pthread_mutex_t *)
malloc(sizeof(pthread_mutex_t));
pthread_mutex_init(source->sum_finished, NULL);
@@ -344,12 +345,12 @@
memcpy(source, hash_datum->data, hash_datum->size);
datum_free(hash_datum);
- source->hosts_up = 0;
- source->hosts_down = 0;
-
/* We need this lock before zeroing metric sums. */
pthread_mutex_lock(source->sum_finished);
+ source->hosts_up = 0;
+ source->hosts_down = 0;
+
hash_foreach(source->metric_summary, zero_out_summary, NULL);
}
@@ -946,7 +947,11 @@
endElement_GRID(void *data, const char *el)
{
xmldata_t *xmldata = (xmldata_t *) data;
+ Source_t *source = &xmldata->source;
+ /*release the partial sum mutex */
+ pthread_mutex_unlock(source->sum_finished);
+
if (gmetad_config.scalable_mode)
{
xmldata->grid_depth--;
@@ -984,7 +989,6 @@
/* We insert here to get an accurate hosts up/down value. */
rdatum = hash_insert( &hashkey, &hashval, xmldata->root);
- source->sum_finished = NULL; /* remember that we released the lock */
if (!rdatum) {
err_msg("Could not insert source %s", xmldata->sourcename);
return 1;
@@ -1060,14 +1064,6 @@
xmldata.rval = 1;
}
- /* Release lock again for good measure (required under certain errors). */
- if (xmldata.source.sum_finished)
- {
- rval = pthread_mutex_unlock(xmldata.source.sum_finished);
- if (rval!=0)
- err_msg("Could not release summary lock for %s", d->name);
- }
-
/* Free memory that might have been allocated in xmldata */
if (xmldata.sourcename)
free(xmldata.sourcename);
Index: gmetad/gmetad.c
===================================================================
--- gmetad/gmetad.c (revision 1139)
+++ gmetad/gmetad.c (working copy)
@@ -191,8 +191,6 @@
/* Need to be sure the source has a complete sum for its metrics. */
pthread_mutex_lock(source->sum_finished);
- /* err_msg("Doing root summary for source %s", source->ds->name); */
-
/* We know that all these metrics are numeric. */
rc = hash_foreach(source->metric_summary, sum_metrics, arg);
@@ -200,6 +198,7 @@
root.hosts_up += source->hosts_up;
root.hosts_down += source->hosts_down;
+ /* summary completed for source */
pthread_mutex_unlock(source->sum_finished);
return rc;
@@ -393,6 +392,11 @@
}
debug_msg("interactive xml listening on port %d", c->interactive_port);
+ /* initialize summary mutex */
+ root.sum_finished = (pthread_mutex_t *)
+ malloc(sizeof(pthread_mutex_t));
+ pthread_mutex_init(root.sum_finished, NULL);
+
pthread_attr_init( &attr );
pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_DETACHED );
@@ -417,6 +421,9 @@
sleep_time = 10 + ((30-10)*1.0) * rand()/(RAND_MAX + 1.0);
sleep(sleep_time);
+ /* Need to be sure root is locked while doing summary */
+ pthread_mutex_lock(root.sum_finished);
+
/* Flush the old values */
hash_foreach(root.metric_summary, zero_out_summary, NULL);
root.hosts_up = 0;
@@ -425,10 +432,12 @@
/* Sum the new values */
hash_foreach(root.authority, do_root_summary, NULL );
+ /* summary completed */
+ pthread_mutex_unlock(root.sum_finished);
+
/* Save them to RRD */
hash_foreach(root.metric_summary, write_root_summary, NULL);
}
return 0;
}
-
Index: gmetad/server.c
===================================================================
--- gmetad/server.c (revision 1139)
+++ gmetad/server.c (working copy)
@@ -106,7 +106,11 @@
source->hosts_up, source->hosts_down);
if (rc) return 1;
- return hash_foreach(source->metric_summary, metric_summary, (void*) client);
+ pthread_mutex_lock(source->sum_finished);
+ rc = hash_foreach(source->metric_summary, metric_summary, (void*) client);
+ pthread_mutex_unlock(source->sum_finished);
+
+ return rc;
}
@@ -254,7 +258,6 @@
return 0;
}
-
int
applyfilter(client_t *client, Generic_t *node)
{
@@ -273,7 +276,7 @@
return 0;
case SUMMARY:
- return source_summary((Source_t*) node, client);
+ return source_summary((Source_t*) node, client);
default:
break;
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Ganglia-developers mailing list
Ganglia-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ganglia-developers