Browse Source

Support keep-alive vrequest reset, which keeps some request data to be shown in mod_status

personal/stbuehler/wip
Stefan Bühler 13 years ago
parent
commit
a49d51bdd3
  1. 7
      include/lighttpd/virtualrequest.h
  2. 12
      src/main/connection.c
  3. 12
      src/main/virtualrequest.c

7
include/lighttpd/virtualrequest.h

@ -107,7 +107,10 @@ struct liVRequest {
LI_API liVRequest* li_vrequest_new(liConnection *con, liVRequestHandlerCB handle_response_headers, liVRequestHandlerCB handle_response_body, liVRequestHandlerCB handle_response_error, liVRequestHandlerCB handle_request_headers);
LI_API void li_vrequest_free(liVRequest *vr);
LI_API void li_vrequest_reset(liVRequest *vr);
/* if keepalive = TRUE, you either have to reset it later again with FALSE or call li_vrequest_start before reusing the vr;
* keepalive = TRUE doesn't reset the vr->request fields, so mod_status can show the last request data in the keep-alive state
*/
LI_API void li_vrequest_reset(liVRequest *vr, gboolean keepalive);
LI_API liVRequestRef* li_vrequest_acquire_ref(liVRequest *vr);
LI_API liVRequest* li_vrequest_release_ref(liVRequestRef *vr_ref);
@ -122,6 +125,8 @@ LI_API void li_vrequest_backend_overloaded(liVRequest *vr);
LI_API void li_vrequest_backend_dead(liVRequest *vr);
LI_API void li_vrequest_backend_error(liVRequest *vr, liBackendError berror);
/* resets fields which weren't reset in favor of keep-alive tracking */
LI_API void li_vrequest_start(liVRequest *vr);
/* received all request headers */
LI_API void li_vrequest_handle_request_headers(liVRequest *vr);
/* received (partial) request content */

12
src/main/connection.c

@ -117,15 +117,12 @@ static void li_connection_internal_error(liConnection *con) {
}
li_connection_error(con);
} else {
liHttpVersion v;
if (CORE_OPTION(LI_CORE_OPTION_DEBUG_REQUEST_HANDLING).boolean) {
VR_DEBUG(vr, "%s", "internal error");
}
/* We only need the http version from the http request */
v = con->mainvr->request.http_version;
li_vrequest_reset(con->mainvr);
con->mainvr->request.http_version = v;
/* We only need the http version from the http request, "keep-alive" reset doesn't reset it */
li_vrequest_reset(con->mainvr, TRUE);
con->keep_alive = FALSE;
con->mainvr->response.http_status = 500;
@ -160,6 +157,7 @@ static gboolean connection_handle_read(liConnection *con) {
con->state = LI_CON_STATE_READ_REQUEST_HEADER;
con->ts = CUR_TS(con->wrk);
li_vrequest_start(con->mainvr);
} else {
if (con->state == LI_CON_STATE_REQUEST_START)
con->state = LI_CON_STATE_READ_REQUEST_HEADER;
@ -517,7 +515,7 @@ void li_connection_reset(liConnection *con) {
}
ev_io_set(&con->sock_watcher, -1, 0);
li_vrequest_reset(con->mainvr);
li_vrequest_reset(con->mainvr, FALSE);
li_http_request_parser_reset(&con->req_parser_ctx);
g_string_truncate(con->remote_addr_str, 0);
@ -626,7 +624,7 @@ static void li_connection_reset_keep_alive(liConnection *con) {
con->raw_out->is_closed = FALSE;
li_vrequest_reset(con->mainvr);
li_vrequest_reset(con->mainvr, TRUE);
li_http_request_parser_reset(&con->req_parser_ctx);
con->ts = CUR_TS(con->wrk);

12
src/main/virtualrequest.c

@ -206,7 +206,7 @@ void li_vrequest_free(liVRequest* vr) {
g_slice_free(liVRequest, vr);
}
void li_vrequest_reset(liVRequest *vr) {
void li_vrequest_reset(liVRequest *vr, gboolean keepalive) {
li_action_stack_reset(vr, &vr->action_stack);
li_plugins_handle_vrclose(vr);
{
@ -219,7 +219,8 @@ void li_vrequest_reset(liVRequest *vr) {
vr->backend = NULL;
li_request_reset(&vr->request);
/* don't reset request for keep-alive tracking */
if (!keepalive) li_request_reset(&vr->request);
li_physical_reset(&vr->physical);
li_response_reset(&vr->response);
li_environment_reset(&vr->env);
@ -290,6 +291,13 @@ void li_vrequest_backend_dead(liVRequest *vr) {
}
/* resets fields which weren't reset in favor of keep-alive tracking */
void li_vrequest_start(liVRequest *vr) {
if (LI_VRS_CLEAN == vr->state) {
li_request_reset(&vr->request);
}
}
/* received all request headers */
void li_vrequest_handle_request_headers(liVRequest *vr) {
if (LI_VRS_CLEAN == vr->state) {

Loading…
Cancel
Save