From 1cea5e9e275b40d2ea18526bb57e3d8aace336c9 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Fri, 9 Apr 2010 14:50:58 +0200 Subject: [PATCH] pinba plugin: service_statnode_collect: Coding style changes. --- src/pinba.c | 60 ++++++++++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/src/pinba.c b/src/pinba.c index 77d72381..c3cc6821 100644 --- a/src/pinba.c +++ b/src/pinba.c @@ -224,46 +224,45 @@ static void service_statnode_end (void) pthread_rwlock_unlock(&temp_lock); } -static unsigned int service_statnode_collect (pinba_statres *res, - unsigned int i) +static unsigned int service_statnode_collect (pinba_statres *res, /* {{{ */ + unsigned int index) { pinba_statnode* node; + pinba_time delta; - if(stat_nodes_count==0) return 0; + if (stat_nodes_count == 0) + return 0; /* begin collecting */ - if(i==0){ - pthread_rwlock_wrlock(&temp_lock); - } - - /* find non-empty node */ - //for(node=stat_nodes+i; node->req_count==0 && ++i=stat_nodes_count){ - pthread_rwlock_unlock(&temp_lock); + if (index >= stat_nodes_count) + { + pthread_rwlock_unlock (&temp_lock); return 0; } - node=stat_nodes+i; + node = stat_nodes + index; + delta = now() - node->last_coll; - pinba_time delta=now()-node->last_coll; + res->name = node->name; + res->req_per_sec = node->req_count / delta; - res->name=node->name; - - res->req_per_sec=node->req_count/delta; - - if(node->req_count==0)node->req_count=1; - res->req_time=node->req_time/node->req_count; - res->ru_utime=node->ru_utime/node->req_count; - res->ru_stime=node->ru_stime/node->req_count; - res->ru_stime=node->ru_stime/node->req_count; - res->doc_size=node->doc_size/node->req_count; - res->mem_peak=node->mem_peak/node->req_count; + if (node->req_count == 0) + node->req_count = 1; + + res->req_time = node->req_time / node->req_count; + res->ru_utime = node->ru_utime / node->req_count; + res->ru_stime = node->ru_stime / node->req_count; + res->ru_stime = node->ru_stime / node->req_count; + res->doc_size = node->doc_size / node->req_count; + res->mem_peak = node->mem_peak / node->req_count; - service_statnode_reset(node); - return ++i; -} + service_statnode_reset (node); + return (index + 1); +} /* }}} unsigned int service_statnode_collect */ static void service_statnode_process (pinba_statnode *node, Pinba__Request* request) @@ -433,7 +432,7 @@ static pinba_socket *pinba_socket_open (const char *ip, /* {{{ */ event_add(s->accept_event, NULL); return s; -} /* }}} */ +} /* }}} pinba_socket_open */ static int service_cleanup (void) { @@ -615,8 +614,7 @@ static int plugin_shutdown (void) return 0; } -static int -plugin_submit (const char *plugin_instance, +static int plugin_submit (const char *plugin_instance, const char *type, const pinba_statres *res) { value_t values[6]; @@ -663,4 +661,4 @@ void module_register (void) plugin_register_shutdown ("pinba", plugin_shutdown); } /* void module_register */ -/* vim: set sw=2 sts=2 et : */ +/* vim: set sw=2 sts=2 et fdm=marker : */ -- 2.30.2