Use the wlock when the value is reseted

This commit is contained in:
Babacar TALL
2014-05-20 14:51:14 +02:00
parent c257a9aa98
commit f06df71bfc
5 changed files with 25 additions and 5 deletions
+5 -1
View File
@@ -380,7 +380,11 @@ metrics_loop:
uwsgi_rlock(uwsgi.metrics_lock);
wok = carbon_write(fd, "%s%s.%s.%.*s %llu %llu\n", u_carbon.root_node, u_carbon.hostname, u_carbon.id, um->name_len, um->name, (unsigned long long) *um->value, (unsigned long long) now);
uwsgi_rwunlock(uwsgi.metrics_lock);
if (um->reset_after_push){ *um->value = 0;}
if (um->reset_after_push){
uwsgi_wlock(uwsgi.metrics_lock);
*um->value = 0;
uwsgi_unlock(uwsgi.metrics_lock);
}
if (!wok) goto clear;
um = um->next;
}
+5 -1
View File
@@ -150,7 +150,11 @@ static void rrdtool_push(struct uwsgi_stats_pusher_instance *uspi, time_t now, c
uwsgi_rlock(uwsgi.metrics_lock);
int ret = snprintf(buf, 1024, "N:%lld", (long long) (*um->value));
uwsgi_rwunlock(uwsgi.metrics_lock);
if (um->reset_after_push){ *um->value = 0;}
if (um->reset_after_push){
uwsgi_wlock(uwsgi.metrics_lock);
*um->value = 0;
uwsgi_unlock(uwsgi.metrics_lock);
}
if (ret < 3 || ret >= 1024) {
uwsgi_log("unable to update rrdtool metric for %s\n", um->name);
goto next;
+5 -1
View File
@@ -92,7 +92,11 @@ static void stats_pusher_socket(struct uwsgi_stats_pusher_instance *uspi, time_t
uwsgi_rlock(uwsgi.metrics_lock);
socket_send_metric(ub, uspi, um);
uwsgi_rwunlock(uwsgi.metrics_lock);
if (um->reset_after_push){ *um->value = 0;}
if (um->reset_after_push){
uwsgi_wlock(uwsgi.metrics_lock);
*um->value = 0;
uwsgi_unlock(uwsgi.metrics_lock);
}
um = um->next;
}
uwsgi_buffer_destroy(ub);
+5 -1
View File
@@ -95,7 +95,11 @@ static void stats_pusher_statsd(struct uwsgi_stats_pusher_instance *uspi, time_t
statsd_send_metric(ub, uspi, um->name, um->name_len, *um->value, "|m");
}
uwsgi_rwunlock(uwsgi.metrics_lock);
if (um->reset_after_push){ *um->value = 0;}
if (um->reset_after_push){
uwsgi_wlock(uwsgi.metrics_lock);
*um->value = 0;
uwsgi_unlock(uwsgi.metrics_lock);
}
um = um->next;
}
uwsgi_buffer_destroy(ub);
+5 -1
View File
@@ -94,7 +94,11 @@ static void stats_pusher_zabbix(struct uwsgi_stats_pusher_instance *uspi, time_t
if (uwsgi_buffer_append(zn->ub, "\",\"value\":\"", 11)) { error = 1; goto end;}
if (uwsgi_buffer_num64(zn->ub, *um->value)) { error = 1; goto end;}
if (uwsgi_buffer_append(zn->ub, "\"}", 2)) { error = 1; goto end;}
if (um->reset_after_push){ *um->value = 0;}
if (um->reset_after_push){
uwsgi_wlock(uwsgi.metrics_lock);
*um->value = 0;
uwsgi_unlock(uwsgi.metrics_lock);
}
um = um->next;
if (um) {
if (uwsgi_buffer_append(zn->ub, ",", 1)) { error = 1; goto end;}