[collect] Allow to start collect without worker context

personal/stbuehler/wip
Stefan Bühler 9 years ago
parent 0dd67d972a
commit ff7b73c8a9
  1. 2
      include/lighttpd/collect.h
  2. 12
      src/main/collect.c

@ -28,6 +28,8 @@ typedef struct liCollectInfo liCollectInfo;
/** li_collect_start returns NULL if the callback was called directly (e.g. for only one worker and ctx = wrk) */
LI_API liCollectInfo* li_collect_start(liWorker *ctx, liCollectFuncCB func, gpointer fdata, liCollectCB cb, gpointer cbdata);
/** li_collect_start_global uses srv->main_worker to call cb(), and never returns direclty */
LI_API liCollectInfo* li_collect_start_global(liServer *srv, liCollectFuncCB func, gpointer fdata, liCollectCB cb, gpointer cbdata);
LI_API void li_collect_break(liCollectInfo* ci); /** this will result in complete == FALSE in the callback; call it if cbdata gets invalid */
/* internal functions */

@ -74,9 +74,8 @@ static gboolean collect_send_result(liWorker *ctx, liCollectInfo *ci) {
}
/* returns true if callback was called directly */
static gboolean collect_insert_func(liWorker *ctx, liCollectInfo *ci) {
static gboolean collect_insert_func(liServer *srv, liWorker *ctx, liCollectInfo *ci) {
guint i;
liServer *srv = ctx->srv;
for (i = 0; i < srv->worker_count; i++) {
liWorker *wrk;
wrk = g_array_index(srv->workers, liWorker*, i);
@ -97,10 +96,17 @@ static gboolean collect_insert_func(liWorker *ctx, liCollectInfo *ci) {
liCollectInfo* li_collect_start(liWorker *ctx, liCollectFuncCB func, gpointer fdata, liCollectCB cb, gpointer cbdata) {
liCollectInfo *ci = collect_info_new(ctx, func, fdata, cb, cbdata);
if (collect_insert_func(ctx, ci)) return NULL; /* collect info is invalid now */
if (collect_insert_func(ctx->srv, ctx, ci)) return NULL; /* collect info is invalid now */
return ci;
}
liCollectInfo* li_collect_start_global(liServer *srv, liCollectFuncCB func, gpointer fdata, liCollectCB cb, gpointer cbdata) {
liCollectInfo *ci = collect_info_new(srv->main_worker, func, fdata, cb, cbdata);
if (collect_insert_func(srv, NULL, ci)) return NULL; /* collect info is invalid now */
return ci;
}
void li_collect_break(liCollectInfo* ci) {
ci->stopped = TRUE;
}

Loading…
Cancel
Save