Live upgrade: store client_heard table to status json

(is not reloaded yet)
This commit is contained in:
Heikki Hannikainen 2012-10-23 16:43:00 +03:00
parent 412abaac3c
commit 9f0b6f05ca
3 changed files with 30 additions and 1 deletions

View File

@ -240,7 +240,6 @@ static void heard_free_single(struct client_heard_t **list)
}
list[i] = NULL;
}
}
void client_heard_free(struct client_t *c)
@ -263,6 +262,27 @@ void client_heard_init(void)
#endif
}
/*
* Generate JSON tree containing a client_heard_t list
*/
struct cJSON *client_heard_json(struct client_heard_t **list)
{
struct client_heard_t *h;
int i;
cJSON *j = cJSON_CreateArray();
for (i = 0; i < CLIENT_HEARD_BUCKETS; i++) {
h = list[i];
while (h) {
cJSON_AddItemToArray(j, cJSON_CreateString(h->callsign));
h = h->next;
}
}
return j;
}
/*
* cellmalloc status
*/

View File

@ -13,6 +13,7 @@
#include "worker.h"
#include "cellmalloc.h"
#include "cJSON.h"
extern void client_heard_update(struct client_t *c, struct pbuf_t *pb);
extern void client_courtesy_update(struct client_t *c, struct pbuf_t *pb);
@ -22,6 +23,8 @@ extern int client_courtesy_needed(struct client_t *c, const char *callsign, int
extern void client_heard_free(struct client_t *c);
extern void client_heard_init(void);
extern struct cJSON *client_heard_json(struct client_heard_t **list);
#ifndef _FOR_VALGRIND_
extern void client_heard_cell_stats(struct cellstatus_t *cellst);
#endif

View File

@ -1890,6 +1890,12 @@ static struct cJSON *worker_client_json(struct client_t *c, int liveup_info)
hlog(LOG_DEBUG, "Hex: %s", s);
hfree(s);
}
/* If message routing for stations heard by this client is enabled,
* dump the client_heard hash table, too.
*/
if (c->flags & CLFLAGS_IGATE)
cJSON_AddItemToObject(jc, "client_heard", client_heard_json(c->client_heard));
}
if (c->state == CSTATE_COREPEER) {