2
0
Fork 0

update mod_fortune and mod_status for new action context

personal/stbuehler/wip
Thomas Porzelt 2008-12-10 17:33:36 +01:00
parent 20e0a9e4e8
commit 52c3c2e042
2 changed files with 24 additions and 7 deletions

View File

@ -41,9 +41,11 @@ static GString *fortune_rand(fortune_data *fd) {
return g_array_index(fd->cookies, GString*, r);
}
static handler_t fortune_header_handle(vrequest *vr, gpointer param) {
static handler_t fortune_header_handle(vrequest *vr, gpointer param, gpointer *context) {
fortune_data *fd = param;
UNUSED(context);
if (fd->cookies->len) {
GString *cookie = fortune_rand(fd);
http_header_insert(vr->response.headers, CONST_STR_LEN("X-fortune"), GSTR_LEN(cookie));
@ -53,12 +55,14 @@ static handler_t fortune_header_handle(vrequest *vr, gpointer param) {
static action* fortune_header(server *srv, plugin* p, value *val) {
UNUSED(srv); UNUSED(val);
return action_new_function(fortune_header_handle, NULL, p->data);
return action_new_function(fortune_header_handle, NULL, NULL, p->data);
}
static handler_t fortune_page_handle(vrequest *vr, gpointer param) {
static handler_t fortune_page_handle(vrequest *vr, gpointer param, gpointer *context) {
fortune_data *fd = param;
UNUSED(context);
if (!vrequest_handle_direct(vr))
return HANDLER_GO_ON;
@ -76,7 +80,7 @@ static handler_t fortune_page_handle(vrequest *vr, gpointer param) {
static action* fortune_page(server *srv, plugin* p, value *val) {
UNUSED(srv); UNUSED(val);
return action_new_function(fortune_page_handle, NULL, p->data);
return action_new_function(fortune_page_handle, NULL, NULL, p->data);
}
static gboolean fortune_load(server *srv, plugin* p, value *val) {

View File

@ -450,22 +450,35 @@ static void status_collect_cb(gpointer cbdata, gpointer fdata, GPtrArray *result
vrequest_joblist_append(vr);
}
static handler_t status_page_handle(vrequest *vr, gpointer param) {
static handler_t status_page_handle(vrequest *vr, gpointer param, gpointer *context) {
UNUSED(param);
if (vr->state == VRS_HANDLE_REQUEST_HEADERS) {
collect_info *ci;
VR_TRACE(vr, "%s", "collecting stats...");
/* abuse fdata as pointer to plugin */
collect_start(vr->con->wrk, status_collect_func, param, NULL, status_collect_cb, vr);
ci = collect_start(vr->con->wrk, status_collect_func, param, NULL, status_collect_cb, vr);
*context = ci;
return HANDLER_WAIT_FOR_EVENT;
}
return HANDLER_GO_ON;
}
static handler_t status_page_cleanup(vrequest *vr, gpointer param, gpointer context) {
collect_info *ci = context;
UNUSED(vr);
UNUSED(param);
collect_break(ci);
return HANDLER_GO_ON;
}
static action* status_page(server *srv, plugin* p, value *val) {
UNUSED(srv); UNUSED(p); UNUSED(val);
return action_new_function(status_page_handle, NULL, p);
return action_new_function(status_page_handle, status_page_cleanup, NULL, p);
}