Fix mod_status handle_direct/WAIT_FOR_EVENT bug

personal/stbuehler/wip
Stefan Bühler 13 years ago
parent 987b28520d
commit 95e8368099
  1. 12
      src/main/virtualrequest.c
  2. 44
      src/modules/mod_status.c

@ -489,11 +489,17 @@ void li_vrequest_state_machine(liVRequest *vr) {
break;
case LI_VRS_READ_CONTENT:
if (CORE_OPTION(LI_CORE_OPTION_DEBUG_REQUEST_HANDLING).boolean) {
VR_DEBUG(vr, "%s", "read content");
}
done = !vrequest_do_handle_read(vr);
done = done || (vr->state == LI_VRS_READ_CONTENT);
break;
case LI_VRS_HANDLE_RESPONSE_HEADERS:
if (CORE_OPTION(LI_CORE_OPTION_DEBUG_REQUEST_HANDLING).boolean) {
VR_DEBUG(vr, "%s", "handle response header");
}
switch (vrequest_do_handle_actions(vr)) {
case LI_HANDLER_GO_ON:
break;
@ -523,12 +529,18 @@ void li_vrequest_state_machine(liVRequest *vr) {
break;
case LI_VRS_WRITE_CONTENT:
if (CORE_OPTION(LI_CORE_OPTION_DEBUG_REQUEST_HANDLING).boolean) {
VR_DEBUG(vr, "%s", "write content");
}
vrequest_do_handle_read(vr);
vrequest_do_handle_write(vr);
done = TRUE;
break;
case LI_VRS_ERROR:
if (CORE_OPTION(LI_CORE_OPTION_DEBUG_REQUEST_HANDLING).boolean) {
VR_DEBUG(vr, "%s", "error");
}
/* this will probably reset the vrequest, so stop handling after it */
vr->handle_response_error(vr);
return;

@ -704,6 +704,7 @@ static void status_collect_cb(gpointer cbdata, gpointer fdata, GPtrArray *result
g_string_free(tmpstr, TRUE);
vr->response.http_status = 200;
li_vrequest_handle_direct(vr);
li_vrequest_joblist_append(vr);
} else {
@ -715,6 +716,8 @@ static void status_collect_cb(gpointer cbdata, gpointer fdata, GPtrArray *result
static liHandlerResult status_info(liVRequest *vr, gpointer _param, gpointer *context) {
mod_status_param *param = _param;
gchar *val;
guint len;
switch (vr->request.http_method) {
case LI_HTTP_METHOD_GET:
@ -724,31 +727,29 @@ static liHandlerResult status_info(liVRequest *vr, gpointer _param, gpointer *co
return LI_HANDLER_GO_ON;
}
if (li_vrequest_handle_direct(vr)) {
gchar *val;
guint len;
if (li_vrequest_is_handled(vr)) return LI_HANDLER_GO_ON;
if (!li_querystring_find(vr->request.uri.query, CONST_STR_LEN("mode"), &val, &len)) {
/* no 'mode' query parameter given */
liCollectInfo *ci;
mod_status_job *j = g_slice_new(mod_status_job);
j->vr = vr;
j->context = context;
j->p = param->p;
j->short_info = param->short_info;
if (!li_querystring_find(vr->request.uri.query, CONST_STR_LEN("mode"), &val, &len)) {
/* no 'mode' query parameter given */
liCollectInfo *ci;
mod_status_job *j = g_slice_new(mod_status_job);
j->vr = vr;
j->context = context;
j->p = param->p;
j->short_info = param->short_info;
VR_DEBUG(vr, "%s", "collecting stats...");
VR_DEBUG(vr, "%s", "collecting stats...");
ci = li_collect_start(vr->wrk, status_collect_func, j, status_collect_cb, NULL);
*context = ci; /* may be NULL */
return (*context) ? LI_HANDLER_WAIT_FOR_EVENT : LI_HANDLER_GO_ON;
ci = li_collect_start(vr->wrk, status_collect_func, j, status_collect_cb, NULL);
*context = ci; /* may be NULL */
return ci ? LI_HANDLER_WAIT_FOR_EVENT : LI_HANDLER_GO_ON;
} else {
/* 'mode' parameter given */
if (!param->short_info && strncmp(val, "runtime", len) == 0) {
return status_info_runtime(vr, param->p);
} else {
/* 'mode' parameter given */
if (!param->short_info && strncmp(val, "runtime", len) == 0) {
return status_info_runtime(vr, param->p);
} else {
vr->response.http_status = 403;
}
vr->response.http_status = 403;
li_vrequest_handle_direct(vr);
}
}
@ -998,6 +999,7 @@ static liHandlerResult status_info_runtime(liVRequest *vr, liPlugin *p) {
li_http_header_overwrite(vr->response.headers, CONST_STR_LEN("Content-Type"), CONST_STR_LEN("text/html"));
vr->response.http_status = 200;
li_vrequest_handle_direct(vr);
return LI_HANDLER_GO_ON;
}

Loading…
Cancel
Save