Browse Source

Move options from connection to vrequest

personal/stbuehler/wip
Stefan Bühler 14 years ago
parent
commit
c24704dad5
  1. 2
      include/lighttpd/connection.h
  2. 6
      include/lighttpd/plugin.h
  3. 3
      include/lighttpd/virtualrequest.h
  4. 2
      src/actions.c
  5. 8
      src/connection.c
  6. 7
      src/virtualrequest.c

2
include/lighttpd/connection.h

@ -41,8 +41,6 @@ struct connection {
GString *remote_addr_str, *local_addr_str;
gboolean is_ssl, keep_alive;
option_value *options;
vrequest *mainvr;
http_request_ctx req_parser_ctx;

6
include/lighttpd/plugin.h

@ -137,9 +137,9 @@ LI_API gboolean call_setup(server *srv, const char *name, value *val);
/** free val after call */
LI_API gboolean plugin_set_default_option(server *srv, const gchar* name, value *val);
/* needs connection *con and plugin *p */
/* needs vrequest *vr and plugin *p */
#define OPTION(idx) _OPTION(vr, p, idx)
#define _OPTION(vr, p, idx) (vr->con->options[p->opt_base_index + idx])
#define _OPTION_ABS(vr, idx) (vr->con->options[idx])
#define _OPTION(vr, p, idx) (vr->options[p->opt_base_index + idx])
#define _OPTION_ABS(vr, idx) (vr->options[idx])
#endif

3
include/lighttpd/virtualrequest.h

@ -52,7 +52,8 @@ struct connection;
struct vrequest {
struct connection *con;
/* TODO: move options from con */
option_value *options;
vrequest_state state;
vrequest_handler

2
src/actions.c

@ -168,7 +168,7 @@ handler_t action_execute(vrequest *vr) {
switch (a->type) {
case ACTION_TSETTING:
vr->con->options[a->data.setting.ndx] = a->data.setting.value;
vr->options[a->data.setting.ndx] = a->data.setting.value;
action_stack_pop(srv, vr, as);
break;
case ACTION_TFUNCTION:

8
src/connection.c

@ -316,8 +316,6 @@ connection* connection_new(worker *wrk) {
con->raw_in = chunkqueue_new();
con->raw_out = chunkqueue_new();
con->options = g_slice_copy(srv->option_def_values->len * sizeof(option_value), srv->option_def_values->data);
con->mainvr = vrequest_new(con,
mainvr_handle_response_headers,
mainvr_handle_response_body,
@ -365,8 +363,6 @@ void connection_reset(connection *con) {
chunkqueue_reset(con->raw_in);
chunkqueue_reset(con->raw_out);
memcpy(con->options, con->srv->option_def_values->data, con->srv->option_def_values->len * sizeof(option_value));
http_request_parser_reset(&con->req_parser_ctx);
if (con->keep_alive_data.link) {
@ -426,8 +422,6 @@ void connection_reset_keep_alive(connection *con) {
con->raw_out->is_closed = FALSE;
memcpy(con->options, con->srv->option_def_values->data, con->srv->option_def_values->len * sizeof(option_value));
vrequest_reset(con->mainvr);
http_request_parser_reset(&con->req_parser_ctx);
@ -468,8 +462,6 @@ void connection_free(connection *con) {
chunkqueue_free(con->raw_in);
chunkqueue_free(con->raw_out);
g_slice_free1(con->srv->option_def_values->len * sizeof(option_value), con->options);
vrequest_free(con->mainvr);
http_request_parser_clear(&con->req_parser_ctx);

7
src/virtualrequest.c

@ -38,6 +38,7 @@ static void filters_reset(filters *fs) {
}
vrequest* vrequest_new(connection *con, vrequest_handler handle_response_headers, vrequest_handler handle_response_body, vrequest_handler handle_response_error, vrequest_handler handle_request_headers) {
server *srv = con->srv;
vrequest *vr = g_slice_new0(vrequest);
vr->con = con;
@ -48,6 +49,8 @@ vrequest* vrequest_new(connection *con, vrequest_handler handle_response_headers
vr->handle_response_error = handle_response_error;
vr->handle_request_headers = handle_request_headers;
vr->options = g_slice_copy(srv->option_def_values->len * sizeof(option_value), srv->option_def_values->data);
request_init(&vr->request);
physical_init(&vr->physical);
response_init(&vr->response);
@ -74,6 +77,8 @@ void vrequest_free(vrequest* vr) {
action_stack_clear(vr, &vr->action_stack);
g_slice_free1(vr->con->srv->option_def_values->len * sizeof(option_value), vr->options);
g_slice_free(vrequest, vr);
}
@ -90,6 +95,8 @@ void vrequest_reset(vrequest *vr) {
filters_reset(&vr->filters_out);
action_stack_reset(vr, &vr->action_stack);
memcpy(vr->options, vr->con->srv->option_def_values->data, vr->con->srv->option_def_values->len * sizeof(option_value));
}
void vrequest_error(vrequest *vr) {

Loading…
Cancel
Save