counterdata & uplink: add and fix comments. Remove unused

signal handler from uplink thread.
This commit is contained in:
Heikki Hannikainen 2012-09-21 01:58:45 +03:00
parent cfda722aab
commit c9b3d1b5fb
2 changed files with 33 additions and 19 deletions

View File

@ -39,6 +39,10 @@ struct cdata_t {
struct cdata_t *counterdata = NULL;
pthread_mutex_t counterdata_mt = PTHREAD_MUTEX_INITIALIZER;
/*
* allocation and freeing of cdata structures
*/
struct cdata_t *cdata_alloc(const char *name)
{
int e;
@ -83,6 +87,10 @@ void cdata_free(struct cdata_t *cd)
hfree(cd);
}
/*
* Find a cdata element by name and lock it for use
*/
static struct cdata_t *cdata_find_and_lock(const char *name)
{
struct cdata_t *cd = NULL;
@ -110,6 +118,10 @@ static struct cdata_t *cdata_find_and_lock(const char *name)
return cd;
}
/*
* Add a new data sample to a counter-watching cdata
*/
void cdata_counter_sample(struct cdata_t *cd, long long value)
{
int e;
@ -146,6 +158,10 @@ void cdata_counter_sample(struct cdata_t *cd, long long value)
}
}
/*
* Add a new sample to a gauge-watching cdata
*/
void cdata_gauge_sample(struct cdata_t *cd, long long value)
{
int e;
@ -171,6 +187,10 @@ void cdata_gauge_sample(struct cdata_t *cd, long long value)
}
}
/*
* Get the last calculated value of a cdata
*/
long cdata_get_last_value(const char *name)
{
int e;
@ -196,6 +216,13 @@ long cdata_get_last_value(const char *name)
return v;
}
/*
* Return a JSON string containing the contents of a cdata array.
* Allocated on the heap, needs to be freed by the caller.
* This is called by the http service to provide graph data for the
* web UI.
*/
char *cdata_json_string(const char *name)
{
struct cdata_t *cd;

View File

@ -10,7 +10,8 @@
*/
/*
* uplink.c: processes uplink data within the worker thread
* uplink thread: create uplink connections as necessary
* (and tear them down)
*/
#include <string.h>
@ -57,24 +58,6 @@ struct portaccount_t uplink_connects = {
.refcount = 99, /* Global static blocks have extra-high initial refcount */
};
/*
* signal handler
*/
int uplink_sighandler(int signum)
{
switch (signum) {
default:
hlog(LOG_WARNING, "* SIG %d ignored", signum);
break;
}
signal(signum, (void *)uplink_sighandler); /* restore handler */
return 0;
}
/*
* Close uplinking sockets
*/
@ -105,6 +88,10 @@ void close_uplinkers(void)
return;
}
/*
* Log and handle the closing of an uplink.
*/
void uplink_close(struct client_t *c, int errnum)
{
int rc;