Browse Source

[multiple] connection hooks no longer get (srv *)

(explicit (server *) not passed; available in con->srv)
personal/stbuehler/ci-build
Glenn Strauss 2 years ago
parent
commit
50bdb55de8
  1. 4
      src/base.h
  2. 8
      src/configfile.c
  3. 8
      src/connections-glue.c
  4. 99
      src/connections.c
  5. 4
      src/connections.h
  6. 73
      src/gw_backend.c
  7. 12
      src/gw_backend.h
  8. 13
      src/http-header-glue.c
  9. 2
      src/http_vhostdb.h
  10. 1
      src/mod_access.c
  11. 10
      src/mod_accesslog.c
  12. 7
      src/mod_alias.c
  13. 3
      src/mod_auth.c
  14. 1
      src/mod_authn_gssapi.c
  15. 46
      src/mod_cgi.c
  16. 2
      src/mod_cml.c
  17. 50
      src/mod_compress.c
  18. 5
      src/mod_deflate.c
  19. 11
      src/mod_dirlisting.c
  20. 5
      src/mod_evasive.c
  21. 4
      src/mod_evhost.c
  22. 3
      src/mod_expire.c
  23. 7
      src/mod_extforward.c
  24. 21
      src/mod_fastcgi.c
  25. 1
      src/mod_flv_streaming.c
  26. 1
      src/mod_geoip.c
  27. 4
      src/mod_indexfile.c
  28. 67
      src/mod_magnet.c
  29. 6
      src/mod_magnet_cache.c
  30. 3
      src/mod_magnet_cache.h
  31. 2
      src/mod_maxminddb.c
  32. 6
      src/mod_mysql_vhost.c
  33. 12
      src/mod_openssl.c
  34. 16
      src/mod_proxy.c
  35. 5
      src/mod_redirect.c
  36. 18
      src/mod_rewrite.c
  37. 1
      src/mod_rrdtool.c
  38. 27
      src/mod_scgi.c
  39. 2
      src/mod_secdownload.c
  40. 4
      src/mod_setenv.c
  41. 10
      src/mod_simple_vhost.c
  42. 1
      src/mod_skeleton.c
  43. 10
      src/mod_sockproxy.c
  44. 5
      src/mod_ssi.c
  45. 1
      src/mod_staticfile.c
  46. 21
      src/mod_status.c
  47. 2
      src/mod_trigger_b4_dl.c
  48. 4
      src/mod_uploadprogress.c
  49. 1
      src/mod_userdir.c
  50. 8
      src/mod_usertrack.c
  51. 5
      src/mod_vhostdb.c
  52. 3
      src/mod_vhostdb_dbi.c
  53. 3
      src/mod_vhostdb_ldap.c
  54. 3
      src/mod_vhostdb_mysql.c
  55. 3
      src/mod_vhostdb_pgsql.c
  56. 13
      src/mod_webdav.c
  57. 22
      src/mod_wstunnel.c
  58. 41
      src/plugin.c
  59. 62
      src/plugin.h
  60. 4
      src/plugin_config.h
  61. 28
      src/response.c
  62. 2
      src/response.h
  63. 11
      src/stat_cache.c
  64. 4
      src/stat_cache.h
  65. 3
      src/t/test_mod_evhost.c
  66. 3
      src/t/test_mod_simple_vhost.c

4
src/base.h

@ -214,12 +214,14 @@ struct connection {
server *srv;
void *plugin_slots;
void **plugin_ctx; /* plugin connection specific config */
specific_config conf; /* global connection specific config */
uint32_t conditional_is_valid;
struct cond_cache_t *cond_cache;
struct cond_match_t *cond_match;
void *config_data_base;
const buffer *server_name;
buffer *proto;
@ -323,7 +325,7 @@ struct server {
struct fdevents *ev;
int (* network_backend_write)(int fd, chunkqueue *cq, off_t max_bytes, log_error_st *errh);
handler_t (* request_env)(struct server *srv, connection *con);
handler_t (* request_env)(connection *con);
/* buffers */
buffer *tmp_buf;

8
src/configfile.c

@ -186,8 +186,8 @@ static void config_merge_config(specific_config * const pconf, const config_plug
} while ((++cpv)->k_id != -1);
}
void config_patch_config(server * const srv, connection * const con) {
config_data_base * const p = srv->config_data_base;
void config_patch_config(connection * const con) {
config_data_base * const p = con->config_data_base;
/* performed by config_reset_config() */
/*memcpy(&con->conf, &p->defaults, sizeof(specific_config));*/
@ -198,9 +198,9 @@ void config_patch_config(server * const srv, connection * const con) {
}
}
void config_reset_config(server * const srv, connection * const con) {
void config_reset_config(connection * const con) {
/* initialize specific_config (con->conf) from top-level specific_config */
config_data_base * const p = srv->config_data_base;
config_data_base * const p = con->config_data_base;
con->server_name = p->defaults.server_name;
memcpy(&con->conf, &p->defaults, sizeof(specific_config));
}

8
src/connections-glue.c

@ -411,14 +411,14 @@ static int connection_write_100_continue(connection *con) {
return 1; /* success; sent all or none of "HTTP/1.1 100 Continue" */
}
handler_t connection_handle_read_post_state(server *srv, connection *con) {
handler_t connection_handle_read_post_state(connection *con) {
chunkqueue *cq = con->read_queue;
chunkqueue *dst_cq = con->request_content_queue;
int is_closed = 0;
if (con->is_readable) {
con->read_idle_ts = srv->cur_ts;
con->read_idle_ts = con->srv->cur_ts;
switch(con->network_read(con, con->read_queue, MAX_READ_LIMIT)) {
case -1:
@ -486,9 +486,7 @@ handler_t connection_handle_read_post_state(server *srv, connection *con) {
}
}
void connection_response_reset(server *srv, connection *con) {
UNUSED(srv);
void connection_response_reset(connection *con) {
con->mode = DIRECT;
con->http_status = 0;
con->is_writable = 1;

99
src/connections.c

@ -39,7 +39,7 @@
__attribute_cold__
static connection *connection_init(server *srv);
static int connection_reset(server *srv, connection *con);
static int connection_reset(connection *con);
static connection *connections_get_new_connection(server *srv) {
@ -53,7 +53,7 @@ static connection *connections_get_new_connection(server *srv) {
for (i = conns->used; i < conns->size; i++) {
conns->ptr[i] = connection_init(srv);
connection_reset(srv, conns->ptr[i]);
connection_reset(conns->ptr[i]);
}
}
@ -62,12 +62,6 @@ static connection *connections_get_new_connection(server *srv) {
}
static int connection_del(server *srv, connection *con) {
size_t i;
connections * const conns = &srv->conns;
connection *temp;
if (con == NULL) return -1;
if (-1 == con->ndx) return -1;
buffer_clear(con->uri.authority);
@ -75,12 +69,14 @@ static int connection_del(server *srv, connection *con) {
buffer_reset(con->uri.query);
buffer_reset(con->request.orig_uri);
i = con->ndx;
connections * const conns = &srv->conns;
uint32_t i = con->ndx;
/* not last element */
if (i != conns->used - 1) {
temp = conns->ptr[i];
connection * const temp = conns->ptr[i];
conns->ptr[i] = conns->ptr[conns->used - 1];
conns->ptr[conns->used - 1] = temp;
@ -117,7 +113,7 @@ static void connection_plugin_ctx_check(server *srv, connection *con) {
static int connection_close(server *srv, connection *con) {
if (con->fd < 0) con->fd = -con->fd;
plugins_call_handle_connection_close(srv, con);
plugins_call_handle_connection_close(con);
con->request_count = 0;
chunkqueue_reset(con->read_queue);
@ -200,10 +196,10 @@ static void connection_handle_close_state(server *srv, connection *con) {
}
static void connection_handle_shutdown(server *srv, connection *con) {
plugins_call_handle_connection_shut_wr(srv, con);
plugins_call_handle_connection_shut_wr(con);
srv->con_closed++;
connection_reset(srv, con);
connection_reset(con);
/* close the connection */
if (con->fd >= 0
@ -225,13 +221,15 @@ static void connection_fdwaitqueue_append(connection *con) {
connection_list_append(&con->srv->fdwaitqueue, con);
}
static void connection_handle_response_end_state(server *srv, connection *con) {
static void connection_handle_response_end_state(connection *con) {
/* log the request */
/* (even if error, connection dropped, still write to access log if http_status) */
if (con->http_status) {
plugins_call_handle_request_done(srv, con);
plugins_call_handle_request_done(con);
}
server * const srv = con->srv;
if (con->state != CON_STATE_ERROR) srv->con_written++;
if (con->request.content_length != con->request_content_queue->bytes_in
@ -241,7 +239,7 @@ static void connection_handle_response_end_state(server *srv, connection *con) {
}
if (con->keep_alive) {
connection_reset(srv, con);
connection_reset(con);
#if 0
con->request_start = srv->cur_ts;
con->read_idle_ts = srv->cur_ts;
@ -284,8 +282,6 @@ static void connection_handle_errdoc(connection *con) {
connection_handle_errdoc_init(con);
con->file_finished = 1;
server * const srv = con->srv;
/* try to send static errorfile */
if (!buffer_string_is_empty(con->conf.errorfile_prefix)) {
buffer_copy_buffer(con->physical.path, con->conf.errorfile_prefix);
@ -293,9 +289,9 @@ static void connection_handle_errdoc(connection *con) {
buffer_append_string_len(con->physical.path, CONST_STR_LEN(".html"));
if (0 == http_chunk_append_file(con, con->physical.path)) {
stat_cache_entry *sce = NULL;
if (stat_cache_get_entry(srv, con, con->physical.path, &sce)
if (stat_cache_get_entry(con, con->physical.path, &sce)
!= HANDLER_ERROR) {
stat_cache_content_type_get(srv, con, con->physical.path, sce);
stat_cache_content_type_get(con, con->physical.path, sce);
http_header_response_set(con, HTTP_HEADER_CONTENT_TYPE,
CONST_STR_LEN("Content-Type"),
CONST_BUF_LEN(sce->content_type));
@ -306,7 +302,7 @@ static void connection_handle_errdoc(connection *con) {
/* build default error-page */
buffer_reset(con->physical.path);
buffer * const b = srv->tmp_buf;
buffer * const b = con->srv->tmp_buf;
buffer_copy_string_len(b, CONST_STR_LEN(
"<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n"
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n"
@ -332,7 +328,7 @@ static void connection_handle_errdoc(connection *con) {
CONST_STR_LEN("text/html"));
}
static int connection_handle_write_prepare(server *srv, connection *con) {
static int connection_handle_write_prepare(connection *con) {
if (con->mode == DIRECT) {
/* static files */
switch(con->request.http_method) {
@ -383,7 +379,7 @@ static int connection_handle_write_prepare(server *srv, connection *con) {
}
/* Allow filter plugins to change response headers before they are written. */
switch(plugins_call_handle_response_start(srv, con)) {
switch(plugins_call_handle_response_start(con)) {
case HANDLER_GO_ON:
case HANDLER_FINISHED:
break;
@ -468,7 +464,7 @@ static int connection_handle_write_prepare(server *srv, connection *con) {
return 0;
}
static void connection_handle_write(server *srv, connection *con) {
static void connection_handle_write(connection *con) {
switch(connection_write_chunkqueue(con, con->write_queue, MAX_WRITE_LIMIT)) {
case 0:
if (con->file_finished) {
@ -489,15 +485,15 @@ static void connection_handle_write(server *srv, connection *con) {
/* not finished yet -> WRITE */
break;
}
con->write_request_ts = srv->cur_ts;
con->write_request_ts = con->srv->cur_ts;
}
static void connection_handle_write_state(server *srv, connection *con) {
static void connection_handle_write_state(connection *con) {
do {
/* only try to write if we have something in the queue */
if (!chunkqueue_is_empty(con->write_queue)) {
if (con->is_writable) {
connection_handle_write(srv, con);
connection_handle_write(con);
if (con->state != CON_STATE_WRITE) break;
}
} else if (con->file_finished) {
@ -506,7 +502,7 @@ static void connection_handle_write_state(server *srv, connection *con) {
}
if (con->mode != DIRECT && !con->file_finished) {
int r = plugins_call_handle_subrequest(srv, con);
int r = plugins_call_handle_subrequest(con);
switch(r) {
case HANDLER_WAIT_FOR_EVENT:
case HANDLER_FINISHED:
@ -537,8 +533,6 @@ __attribute_cold__
static connection *connection_init(server *srv) {
connection *con;
UNUSED(srv);
con = calloc(1, sizeof(*con));
force_assert(NULL != con);
@ -579,6 +573,10 @@ static connection *connection_init(server *srv) {
con->read_queue = chunkqueue_init();
con->request_content_queue = chunkqueue_init();
con->srv = srv;
con->plugin_slots = srv->plugin_slots;
con->config_data_base = srv->config_data_base;
/* init plugin specific connection structures */
con->plugin_ctx = calloc(1, (srv->plugins.used + 1) * sizeof(void *));
@ -592,7 +590,7 @@ static connection *connection_init(server *srv) {
force_assert(NULL != con->cond_match);
}
#endif
config_reset_config(srv, con);
config_reset_config(con);
return con;
}
@ -602,7 +600,7 @@ void connections_free(server *srv) {
for (uint32_t i = 0; i < conns->size; ++i) {
connection *con = conns->ptr[i];
connection_reset(srv, con);
connection_reset(con);
chunkqueue_free(con->write_queue);
chunkqueue_free(con->read_queue);
@ -648,10 +646,10 @@ void connections_free(server *srv) {
}
static int connection_reset(server *srv, connection *con) {
plugins_call_connection_reset(srv, con);
static int connection_reset(connection *con) {
plugins_call_connection_reset(con);
connection_response_reset(srv, con);
connection_response_reset(con);
con->is_readable = 1;
con->bytes_written = 0;
@ -704,7 +702,7 @@ static int connection_reset(server *srv, connection *con) {
/*con->error_handler_saved_method = HTTP_METHOD_UNSET;*/
/*(error_handler_saved_method value is not valid unless error_handler_saved_status is set)*/
config_reset_config(srv, con);
config_reset_config(con);
return 0;
}
@ -902,7 +900,7 @@ static handler_t connection_handle_fdevent(server *srv, void *context, int reven
if (con->state == CON_STATE_WRITE &&
!chunkqueue_is_empty(con->write_queue) &&
con->is_writable) {
connection_handle_write(srv, con);
connection_handle_write(con);
}
if (con->state == CON_STATE_CLOSE) {
@ -1108,8 +1106,6 @@ connection *connection_accepted(server *srv, server_socket *srv_socket, sock_add
srv->con_opened++;
con = connections_get_new_connection(srv);
con->conf.errh = srv->errh;
con->srv = srv;
con->fd = cnt;
con->fdn = fdevent_register(srv->ev, con->fd, connection_handle_fdevent, con);
@ -1129,8 +1125,8 @@ connection *connection_accepted(server *srv, server_socket *srv_socket, sock_add
| (1 << COMP_HTTP_REMOTE_IP);
buffer_copy_string_len(con->proto, CONST_STR_LEN("http"));
if (HANDLER_GO_ON != plugins_call_handle_connection_accept(srv, con)) {
connection_reset(srv, con);
if (HANDLER_GO_ON != plugins_call_handle_connection_accept(con)) {
connection_reset(con);
connection_close(srv, con);
return NULL;
}
@ -1139,8 +1135,8 @@ connection *connection_accepted(server *srv, server_socket *srv_socket, sock_add
}
static int connection_handle_request(server *srv, connection *con) {
int r = http_response_prepare(srv, con);
static int connection_handle_request(connection *con) {
int r = http_response_prepare(con);
switch (r) {
case HANDLER_WAIT_FOR_EVENT:
if (!con->file_finished && (!con->file_started || 0 == con->conf.stream_response_body)) {
@ -1185,11 +1181,12 @@ static int connection_handle_request(server *srv, connection *con) {
/* set REDIRECT_STATUS to save current HTTP status code
* for access by dynamic handlers
* https://redmine.lighttpd.net/issues/1828 */
buffer_copy_int(srv->tmp_buf, con->http_status);
http_header_env_set(con, CONST_STR_LEN("REDIRECT_STATUS"), CONST_BUF_LEN(srv->tmp_buf));
buffer * const tb = con->srv->tmp_buf;
buffer_copy_int(tb, con->http_status);
http_header_env_set(con, CONST_STR_LEN("REDIRECT_STATUS"), CONST_BUF_LEN(tb));
if (error_handler == con->conf.error_handler) {
plugins_call_connection_reset(srv, con);
plugins_call_connection_reset(con);
if (con->request.content_length) {
if (con->request.content_length != con->request_content_queue->bytes_in) {
@ -1230,7 +1227,7 @@ static int connection_handle_request(server *srv, connection *con) {
break;
case HANDLER_COMEBACK:
if (con->mode == DIRECT && buffer_is_empty(con->physical.path)) {
config_reset_config(srv, con);
config_reset_config(con);
}
return 1;
case HANDLER_ERROR:
@ -1286,7 +1283,7 @@ int connection_state_machine(server *srv, connection *con) {
/* fall through */
case CON_STATE_READ_POST:
case CON_STATE_HANDLE_REQUEST:
if (connection_handle_request(srv, con)) {
if (connection_handle_request(con)) {
/* redo loop; will not match con->state */
ostate = CON_STATE_CONNECT;
break;
@ -1300,19 +1297,19 @@ int connection_state_machine(server *srv, connection *con) {
if (con->state != CON_STATE_RESPONSE_START) break;
/* fall through */
case CON_STATE_RESPONSE_START: /* transient */
if (-1 == connection_handle_write_prepare(srv, con)) {
if (-1 == connection_handle_write_prepare(con)) {
connection_set_state(con, CON_STATE_ERROR);
break;
}
connection_set_state(con, CON_STATE_WRITE);
/* fall through */
case CON_STATE_WRITE:
connection_handle_write_state(srv, con);
connection_handle_write_state(con);
if (con->state != CON_STATE_RESPONSE_END) break;
/* fall through */
case CON_STATE_RESPONSE_END: /* transient */
case CON_STATE_ERROR: /* transient */
connection_handle_response_end_state(srv, con);
connection_handle_response_end_state(con);
break;
case CON_STATE_CLOSE:
connection_handle_close_state(srv, con);

4
src/connections.h

@ -18,10 +18,10 @@ connection * connection_accepted(server *srv, server_socket *srv_socket, sock_ad
const char * connection_get_state(connection_state_t state);
const char * connection_get_short_state(connection_state_t state);
int connection_state_machine(server *srv, connection *con);
handler_t connection_handle_read_post_state(server *srv, connection *con);
handler_t connection_handle_read_post_state(connection *con);
handler_t connection_handle_read_post_error(connection *con, int http_status);
int connection_write_chunkqueue(connection *con, chunkqueue *c, off_t max_bytes);
void connection_response_reset(server *srv, connection *con);
void connection_response_reset(connection *con);
#define joblist_append(srv, con) connection_list_append(&(srv)->joblist, (con))
void connection_list_append(connections *conns, connection *con);

73
src/gw_backend.c

@ -649,8 +649,7 @@ static void gw_proc_spawn(server *srv, gw_host *host, int debug) {
}
}
static void gw_proc_kill(server *srv, gw_host *host, gw_proc *proc) {
UNUSED(srv);
static void gw_proc_kill(gw_host *host, gw_proc *proc) {
if (proc->next) proc->next->prev = proc->prev;
if (proc->prev) proc->prev->next = proc->next;
@ -758,7 +757,7 @@ enum {
GW_BALANCE_STICKY
};
static gw_host * gw_host_get(server *srv, connection *con, gw_extension *extension, int balance, int debug) {
static gw_host * gw_host_get(connection *con, gw_extension *extension, int balance, int debug) {
gw_host *host;
unsigned long last_max = ULONG_MAX;
int max_usage = INT_MAX;
@ -774,7 +773,7 @@ static gw_host * gw_host_get(server *srv, connection *con, gw_extension *extensi
/* hash balancing */
if (debug) {
log_error(srv->errh, __FILE__, __LINE__,
log_error(con->conf.errh, __FILE__, __LINE__,
"proxy - used hash balancing, hosts: %u", extension->used);
}
@ -788,7 +787,7 @@ static gw_host * gw_host_get(server *srv, connection *con, gw_extension *extensi
+ generate_crc32c(CONST_BUF_LEN(con->uri.authority));
if (debug) {
log_error(srv->errh, __FILE__, __LINE__,
log_error(con->conf.errh, __FILE__, __LINE__,
"proxy - election: %s %s %s %lu", con->uri.path->ptr,
host->host->ptr, con->uri.authority->ptr, cur_max);
}
@ -803,7 +802,7 @@ static gw_host * gw_host_get(server *srv, connection *con, gw_extension *extensi
case GW_BALANCE_LEAST_CONNECTION:
/* fair balancing */
if (debug) {
log_error(srv->errh, __FILE__, __LINE__,
log_error(con->conf.errh, __FILE__, __LINE__,
"proxy - used least connection");
}
@ -821,7 +820,7 @@ static gw_host * gw_host_get(server *srv, connection *con, gw_extension *extensi
case GW_BALANCE_RR:
/* round robin */
if (debug) {
log_error(srv->errh, __FILE__, __LINE__,
log_error(con->conf.errh, __FILE__, __LINE__,
"proxy - used round-robin balancing");
}
@ -858,7 +857,7 @@ static gw_host * gw_host_get(server *srv, connection *con, gw_extension *extensi
/* source sticky balancing */
if (debug) {
log_error(srv->errh, __FILE__, __LINE__,
log_error(con->conf.errh, __FILE__, __LINE__,
"proxy - used sticky balancing, hosts: %u", extension->used);
}
@ -873,7 +872,7 @@ static gw_host * gw_host_get(server *srv, connection *con, gw_extension *extensi
+ host->port;
if (debug) {
log_error(srv->errh, __FILE__, __LINE__,
log_error(con->conf.errh, __FILE__, __LINE__,
"proxy - election: %s %s %hu %ld", con->dst_addr_buf->ptr,
host->host->ptr, host->port, cur_max);
}
@ -894,18 +893,18 @@ static gw_host * gw_host_get(server *srv, connection *con, gw_extension *extensi
host = extension->hosts[ndx];
if (debug) {
log_error(srv->errh, __FILE__, __LINE__,
log_error(con->conf.errh, __FILE__, __LINE__,
"gw - found a host %s %hu", host->host->ptr, host->port);
}
return host;
} else if (0 == srv->srvconf.max_worker) {
} else if (0 == con->srv->srvconf.max_worker) {
/* special-case adaptive spawning and 0 == host->min_procs */
for (k = 0; k < extension->used; ++k) {
host = extension->hosts[k];
if (0 == host->min_procs && 0 == host->num_procs
&& !buffer_string_is_empty(host->bin_path)) {
gw_proc_spawn(srv, host, debug);
gw_proc_spawn(con->srv, host, debug);
if (host->num_procs) return host;
}
}
@ -919,7 +918,7 @@ static gw_host * gw_host_get(server *srv, connection *con, gw_extension *extensi
/* only send the 'no handler' once */
if (!extension->note_is_sent) {
extension->note_is_sent = 1;
log_error(srv->errh, __FILE__, __LINE__,
log_error(con->conf.errh, __FILE__, __LINE__,
"all handlers for %s?%.*s on %s are down.",
con->uri.path->ptr, BUFFER_INTLEN_PTR(con->uri.query),
extension->key.ptr);
@ -1704,20 +1703,20 @@ int gw_get_defaults_balance(server *srv, const buffer *b) {
}
static void gw_set_state(server *srv, gw_handler_ctx *hctx, gw_connection_state_t state) {
static void gw_set_state(gw_handler_ctx *hctx, gw_connection_state_t state) {
hctx->state = state;
hctx->state_timestamp = srv->cur_ts;
/*hctx->state_timestamp = hctx->remote_conn->srv->cur_ts;*/
}
void gw_set_transparent(server *srv, gw_handler_ctx *hctx) {
void gw_set_transparent(gw_handler_ctx *hctx) {
if (AF_UNIX != hctx->host->family) {
if (-1 == fdevent_set_tcp_nodelay(hctx->fd, 1)) {
/*(error, but not critical)*/
}
}
hctx->wb_reqlen = -1;
gw_set_state(srv, hctx, GW_STATE_WRITE);
gw_set_state(hctx, GW_STATE_WRITE);
}
@ -1757,7 +1756,7 @@ static void gw_connection_close(server *srv, gw_handler_ctx *hctx) {
static handler_t gw_reconnect(server *srv, gw_handler_ctx *hctx) {
gw_backend_close(srv, hctx);
hctx->host = gw_host_get(srv, hctx->remote_conn, hctx->ext,
hctx->host = gw_host_get(hctx->remote_conn, hctx->ext,
hctx->conf.balance, hctx->conf.debug);
if (NULL == hctx->host) return HANDLER_FINISHED;
@ -1765,15 +1764,15 @@ static handler_t gw_reconnect(server *srv, gw_handler_ctx *hctx) {
hctx->request_id = 0;
hctx->opts.xsendfile_allow = hctx->host->xsendfile_allow;
hctx->opts.xsendfile_docroot = hctx->host->xsendfile_docroot;
gw_set_state(srv, hctx, GW_STATE_INIT);
gw_set_state(hctx, GW_STATE_INIT);
return HANDLER_COMEBACK;
}
handler_t gw_connection_reset(server *srv, connection *con, void *p_d) {
handler_t gw_connection_reset(connection *con, void *p_d) {
gw_plugin_data *p = p_d;
gw_handler_ctx *hctx = con->plugin_ctx[p->id];
if (hctx) gw_connection_close(srv, hctx);
if (hctx) gw_connection_close(con->srv, hctx);
return HANDLER_GO_ON;
}
@ -1849,7 +1848,7 @@ static handler_t gw_write_request(server *srv, gw_handler_ctx *hctx) {
hctx->fd, hctx->conf.debug)) {
case 1: /* connection is in progress */
fdevent_fdnode_event_set(srv->ev, hctx->fdn, FDEVENT_OUT);
gw_set_state(srv, hctx, GW_STATE_CONNECT_DELAYED);
gw_set_state(hctx, GW_STATE_CONNECT_DELAYED);
return HANDLER_WAIT_FOR_EVENT;
case -1:/* connection error */
return HANDLER_ERROR;
@ -1871,13 +1870,13 @@ static handler_t gw_write_request(server *srv, gw_handler_ctx *hctx) {
gw_proc_connect_success(srv, hctx->host, hctx->proc, hctx->conf.debug);
gw_set_state(srv, hctx, GW_STATE_PREPARE_WRITE);
gw_set_state(hctx, GW_STATE_PREPARE_WRITE);
/* fall through */
case GW_STATE_PREPARE_WRITE:
/* ok, we have the connection */
{
handler_t rc = hctx->create_env(srv, hctx);
handler_t rc = hctx->create_env(hctx);
if (HANDLER_GO_ON != rc) {
if (HANDLER_FINISHED != rc && HANDLER_ERROR != rc)
fdevent_fdnode_event_clr(srv->ev, hctx->fdn, FDEVENT_OUT);
@ -1896,7 +1895,7 @@ static handler_t gw_write_request(server *srv, gw_handler_ctx *hctx) {
}
fdevent_fdnode_event_add(srv->ev, hctx->fdn, FDEVENT_IN|FDEVENT_RDHUP);
gw_set_state(srv, hctx, GW_STATE_WRITE);
gw_set_state(hctx, GW_STATE_WRITE);
/* fall through */
case GW_STATE_WRITE:
if (!chunkqueue_is_empty(hctx->wb)) {
@ -1937,7 +1936,7 @@ static handler_t gw_write_request(server *srv, gw_handler_ctx *hctx) {
if (hctx->wb->bytes_out == hctx->wb_reqlen) {
fdevent_fdnode_event_clr(srv->ev, hctx->fdn, FDEVENT_OUT);
gw_set_state(srv, hctx, GW_STATE_READ);
gw_set_state(hctx, GW_STATE_READ);
} else {
off_t wblen = hctx->wb->bytes_in - hctx->wb->bytes_out;
if ((hctx->wb->bytes_in < hctx->wb_reqlen || hctx->wb_reqlen < 0)
@ -2004,12 +2003,14 @@ static handler_t gw_send_request(server *srv, gw_handler_ctx *hctx) {
static handler_t gw_recv_response(server *srv, gw_handler_ctx *hctx);
handler_t gw_handle_subrequest(server *srv, connection *con, void *p_d) {
handler_t gw_handle_subrequest(connection *con, void *p_d) {
gw_plugin_data *p = p_d;
gw_handler_ctx *hctx = con->plugin_ctx[p->id];
if (NULL == hctx) return HANDLER_GO_ON;
if (con->mode != p->id) return HANDLER_GO_ON; /* not my job */
server * const srv = con->srv;
if ((con->conf.stream_response_body & FDEVENT_STREAM_RESPONSE_BUFMIN)
&& con->file_started) {
if (chunkqueue_length(con->write_queue) > 65536 - 4096) {
@ -2043,14 +2044,14 @@ handler_t gw_handle_subrequest(server *srv, connection *con, void *p_d) {
if (0 != hctx->wb->bytes_in) return HANDLER_WAIT_FOR_EVENT;
}
else {
handler_t r = connection_handle_read_post_state(srv, con);
handler_t r = connection_handle_read_post_state(con);
chunkqueue *req_cq = con->request_content_queue;
#if 0 /*(not reached since we send 411 Length Required below)*/
if (hctx->wb_reqlen < -1 && con->request.content_length >= 0) {
/* (completed receiving Transfer-Encoding: chunked) */
hctx->wb_reqlen= -hctx->wb_reqlen + con->request.content_length;
if (hctx->stdin_append) {
handler_t rc = hctx->stdin_append(srv, hctx);
handler_t rc = hctx->stdin_append(hctx);
if (HANDLER_GO_ON != rc) return rc;
}
}
@ -2058,7 +2059,7 @@ handler_t gw_handle_subrequest(server *srv, connection *con, void *p_d) {
if ((0 != hctx->wb->bytes_in || -1 == hctx->wb_reqlen)
&& !chunkqueue_is_empty(req_cq)) {
if (hctx->stdin_append) {
handler_t rc = hctx->stdin_append(srv, hctx);
handler_t rc = hctx->stdin_append(hctx);
if (HANDLER_GO_ON != rc) return rc;
}
else
@ -2153,7 +2154,7 @@ static handler_t gw_recv_response(server *srv, gw_handler_ctx *hctx) {
/* restart the request so other handlers can process it */
if (physpath) con->physical.path = NULL;
connection_response_reset(srv,con);/*(includes con->http_status=0)*/
connection_response_reset(con); /*(includes con->http_status=0)*/
/* preserve con->physical.path with modified docroot */
if (physpath) con->physical.path = physpath;
@ -2292,10 +2293,10 @@ static handler_t gw_handle_fdevent(server *srv, void *ctx, int revents) {
return HANDLER_FINISHED;
}
handler_t gw_check_extension(server *srv, connection *con, gw_plugin_data *p, int uri_path_handler, size_t hctx_sz) {
handler_t gw_check_extension(connection *con, gw_plugin_data *p, int uri_path_handler, size_t hctx_sz) {
#if 0 /*(caller must handle)*/
if (con->mode != DIRECT) return HANDLER_GO_ON;
gw_patch_connection(srv, con, p);
gw_patch_connection(con, p);
if (NULL == p->conf.exts) return HANDLER_GO_ON;
#endif
@ -2394,7 +2395,7 @@ handler_t gw_check_extension(server *srv, connection *con, gw_plugin_data *p, in
}
/* check if we have at least one server for this extension up and running */
host = gw_host_get(srv, con, extension, p->conf.balance, p->conf.debug);
host = gw_host_get(con, extension, p->conf.balance, p->conf.debug);
if (NULL == host) {
return HANDLER_FINISHED;
}
@ -2473,7 +2474,7 @@ handler_t gw_check_extension(server *srv, connection *con, gw_plugin_data *p, in
hctx->host = host;
hctx->proc = NULL;
hctx->ext = extension;
gw_host_assign(srv, host);
gw_host_assign(con->srv, host);
hctx->gw_mode = gw_mode;
if (gw_mode == GW_AUTHORIZER) {
@ -2564,7 +2565,7 @@ static void gw_handle_trigger_host(server *srv, gw_host *host, int debug) {
proc->unixsocket->ptr, proc->pid);
}
gw_proc_kill(srv, host, proc);
gw_proc_kill(host, proc);
/* proc is now in unused, let next second handle next process */
break;

12
src/gw_backend.h

@ -319,8 +319,8 @@ typedef struct gw_handler_ctx {
connection *remote_conn; /* dumb pointer */
gw_plugin_data *plugin_data; /* dumb pointer */
handler_t(*stdin_append)(server *srv, struct gw_handler_ctx *hctx);
handler_t(*create_env)(server *srv, struct gw_handler_ctx *hctx);
handler_t(*stdin_append)(struct gw_handler_ctx *hctx);
handler_t(*create_env)(struct gw_handler_ctx *hctx);
void(*backend_error)(struct gw_handler_ctx *hctx);
void(*handler_ctx_free)(void *hctx);
} gw_handler_ctx;
@ -344,12 +344,12 @@ int gw_set_defaults_backend(server *srv, gw_plugin_data *p, const array *a, gw_p
__attribute_cold__
int gw_get_defaults_balance(server *srv, const buffer *b);
handler_t gw_check_extension(server *srv, connection *con, gw_plugin_data *p, int uri_path_handler, size_t hctx_sz);
handler_t gw_connection_reset(server *srv, connection *con, void *p_d);
handler_t gw_handle_subrequest(server *srv, connection *con, void *p_d);
handler_t gw_check_extension(connection *con, gw_plugin_data *p, int uri_path_handler, size_t hctx_sz);
handler_t gw_connection_reset(connection *con, void *p_d);
handler_t gw_handle_subrequest(connection *con, void *p_d);
handler_t gw_handle_trigger(server *srv, void *p_d);
handler_t gw_handle_waitpid_cb(server *srv, void *p_d, pid_t pid, int status);
void gw_set_transparent(server *srv, gw_handler_ctx *hctx);
void gw_set_transparent(gw_handler_ctx *hctx);
#endif

13
src/http-header-glue.c

@ -430,13 +430,12 @@ static int http_response_parse_range(connection *con, buffer *path, stat_cache_e
void http_response_send_file (connection *con, buffer *path) {
server * const srv = con->srv;
stat_cache_entry *sce = NULL;
const buffer *mtime = NULL;
const buffer *vb;
int allow_caching = (0 == con->http_status || 200 == con->http_status);
if (HANDLER_ERROR == stat_cache_get_entry(srv, con, path, &sce)) {
if (HANDLER_ERROR == stat_cache_get_entry(con, path, &sce)) {
con->http_status = (errno == ENOENT) ? 404 : 403;
log_error(con->conf.errh, __FILE__, __LINE__,
"not a regular file: %s -> %s", con->uri.path->ptr, path->ptr);
@ -485,7 +484,7 @@ void http_response_send_file (connection *con, buffer *path) {
/* set response content-type, if not set already */
if (NULL == http_header_response_get(con, HTTP_HEADER_CONTENT_TYPE, CONST_STR_LEN("Content-Type"))) {
stat_cache_content_type_get(srv, con, path, sce);
stat_cache_content_type_get(con, path, sce);
if (buffer_string_is_empty(sce->content_type)) {
/* we are setting application/octet-stream, but also announce that
* this header field might change in the seconds few requests
@ -517,7 +516,7 @@ void http_response_send_file (connection *con, buffer *path) {
/* prepare header */
if (NULL == (mtime = http_header_response_get(con, HTTP_HEADER_LAST_MODIFIED, CONST_STR_LEN("Last-Modified")))) {
mtime = strftime_cache_get(srv, sce->st.st_mtime);
mtime = strftime_cache_get(con->srv, sce->st.st_mtime);
http_header_response_set(con, HTTP_HEADER_LAST_MODIFIED, CONST_STR_LEN("Last-Modified"), CONST_BUF_LEN(mtime));
}
@ -723,7 +722,7 @@ static void http_response_xsendfile2(connection *con, const buffer *value, const
}
}
if (HANDLER_ERROR == stat_cache_get_entry(con->srv, con, b, &sce)) {
if (HANDLER_ERROR == stat_cache_get_entry(con, b, &sce)) {
log_error(con->conf.errh, __FILE__, __LINE__,
"send-file error: couldn't get stat_cache entry for "
"X-Sendfile2: %s", b->ptr);
@ -908,7 +907,7 @@ static handler_t http_response_process_local_redir(connection *con, size_t blen)
}
/*(caller must reset request as follows)*/
/*connection_response_reset(con->srv, con);*/ /*(sets con->http_status = 0)*/
/*connection_response_reset(con);*/ /*(sets con->http_status = 0)*/
/*plugins_call_connection_reset(con->srv, con);*/
return HANDLER_COMEBACK;
@ -1541,7 +1540,7 @@ int http_cgi_headers (connection *con, http_cgi_opts *opts, http_cgi_header_appe
}
}
con->srv->request_env(con->srv, con);
con->srv->request_env(con);
for (n = 0; n < con->environment.used; n++) {
data_string *ds = (data_string *)con->environment.data[n];

2
src/http_vhostdb.h

@ -11,7 +11,7 @@ struct http_vhostdb_backend_t;
typedef struct http_vhostdb_backend_t {
const char *name;
int(*query)(server *srv, connection *con, void *p_d, buffer *result);
int(*query)(connection *con, void *p_d, buffer *result);
void *p_d;
} http_vhostdb_backend_t;

1
src/mod_access.c

@ -149,7 +149,6 @@ static int mod_access_check (const array *allow, const array *deny, const buffer
URIHANDLER_FUNC(mod_access_uri_handler) {
plugin_data *p = p_d;
if (buffer_is_empty(con->uri.path)) return HANDLER_GO_ON;
UNUSED(srv);
mod_access_patch_config(con, p);

10
src/mod_accesslog.c

@ -798,7 +798,7 @@ REQUESTDONE_FUNC(log_access_write) {
if (f->opt & ~(FORMAT_FLAG_TIME_BEGIN|FORMAT_FLAG_TIME_END)) {
if (f->opt & FORMAT_FLAG_TIME_SEC) {
time_t t = (!(f->opt & FORMAT_FLAG_TIME_BEGIN)) ? srv->cur_ts : con->request_start;
time_t t = (!(f->opt & FORMAT_FLAG_TIME_BEGIN)) ? con->srv->cur_ts : con->request_start;
buffer_append_int(b, (intmax_t)t);
} else if (f->opt & (FORMAT_FLAG_TIME_MSEC|FORMAT_FLAG_TIME_USEC|FORMAT_FLAG_TIME_NSEC)) {
off_t t; /*(expected to be 64-bit since large file support enabled)*/
@ -863,11 +863,11 @@ REQUESTDONE_FUNC(log_access_write) {
#endif /* HAVE_STRUCT_TM_GMTOFF */
if (!(f->opt & FORMAT_FLAG_TIME_BEGIN)) {
if (parsed_format->last_generated_accesslog_ts == srv->cur_ts) {
if (parsed_format->last_generated_accesslog_ts == con->srv->cur_ts) {
buffer_append_string_buffer(b, ts_accesslog_str);
break;
}
t = parsed_format->last_generated_accesslog_ts = srv->cur_ts;
t = parsed_format->last_generated_accesslog_ts = con->srv->cur_ts;
flush = 1;
} else {
t = con->request_start;
@ -919,7 +919,7 @@ REQUESTDONE_FUNC(log_access_write) {
case FORMAT_TIME_USED:
case FORMAT_TIME_USED_US:
if (f->opt & FORMAT_FLAG_TIME_SEC) {
buffer_append_int(b, srv->cur_ts - con->request_start);
buffer_append_int(b, con->srv->cur_ts - con->request_start);
} else {
const struct timespec * const bs = &con->request_start_hp;
off_t tdiff; /*(expected to be 64-bit since large file support enabled)*/
@ -1073,7 +1073,7 @@ REQUESTDONE_FUNC(log_access_write) {
if (colon) {
buffer_append_string(b, colon+1);
} else {
buffer_append_int(b, srv->srvconf.port);
buffer_append_int(b, con->srv->srvconf.port);
}
}
break;

7
src/mod_alias.c

@ -164,10 +164,11 @@ PHYSICALPATH_FUNC(mod_alias_physical_handler) {
}
}
buffer * const tb = con->srv->tmp_buf;
buffer_copy_buffer(con->physical.basedir, &ds->value);
buffer_copy_buffer(srv->tmp_buf, &ds->value);
buffer_append_string(srv->tmp_buf, uri_ptr + alias_len);
buffer_copy_buffer(con->physical.path, srv->tmp_buf);
buffer_copy_buffer(tb, &ds->value);
buffer_append_string(tb, uri_ptr + alias_len);
buffer_copy_buffer(con->physical.path, tb);
return HANDLER_GO_ON;
}

3
src/mod_auth.c

@ -466,10 +466,9 @@ SETDEFAULTS_FUNC(mod_auth_set_defaults) {
return HANDLER_GO_ON;
}
static handler_t mod_auth_uri_handler(server *srv, connection *con, void *p_d) {
static handler_t mod_auth_uri_handler(connection *con, void *p_d) {
plugin_data *p = p_d;
data_auth *dauth;
UNUSED(srv);
mod_auth_patch_config(con, p);

1
src/mod_authn_gssapi.c

@ -774,7 +774,6 @@ CONNECTION_FUNC(mod_authn_gssapi_handle_reset) {
buffer_free(kccname);
}
UNUSED(srv);
return HANDLER_GO_ON;
}

46
src/mod_cgi.c

@ -353,16 +353,16 @@ static void cgi_connection_close(server *srv, handler_ctx *hctx) {
}
}
static handler_t cgi_connection_close_callback(server *srv, connection *con, void *p_d) {
static handler_t cgi_connection_close_callback(connection *con, void *p_d) {
plugin_data *p = p_d;
handler_ctx *hctx = con->plugin_ctx[p->id];
if (hctx) cgi_connection_close(srv, hctx);
if (hctx) cgi_connection_close(con->srv, hctx);
return HANDLER_GO_ON;
}
static int cgi_write_request(server *srv, handler_ctx *hctx, int fd);
static int cgi_write_request(handler_ctx *hctx, int fd);
static handler_t cgi_handle_fdevent_send (server *srv, void *ctx, int revents) {
@ -373,7 +373,7 @@ static handler_t cgi_handle_fdevent_send (server *srv, void *ctx, int revents) {
joblist_append(srv, con);
if (revents & FDEVENT_OUT) {
if (0 != cgi_write_request(srv, hctx, hctx->fdtocgi)) {
if (0 != cgi_write_request(hctx, hctx->fdtocgi)) {
cgi_connection_close(srv, hctx);
return HANDLER_ERROR;
}
@ -451,8 +451,8 @@ static int cgi_recv_response(server *srv, handler_ctx *hctx) {
case HANDLER_COMEBACK:
/* hctx->conf.local_redir */
buffer_clear(hctx->response);
connection_response_reset(srv, hctx->remote_conn); /*(includes con->http_status = 0)*/
plugins_call_connection_reset(srv, hctx->remote_conn);
connection_response_reset(hctx->remote_conn); /*(includes con->http_status = 0)*/
plugins_call_connection_reset(hctx->remote_conn);
/*cgi_connection_close(srv, hctx);*//*(already cleaned up and hctx is now invalid)*/
return HANDLER_COMEBACK;
}
@ -651,7 +651,7 @@ static ssize_t cgi_write_file_chunk_mmap(connection *con, int fd, chunkqueue *cq
return r;
}
static int cgi_write_request(server *srv, handler_ctx *hctx, int fd) {
static int cgi_write_request(handler_ctx *hctx, int fd) {
connection *con = hctx->remote_conn;
chunkqueue *cq = con->request_content_queue;
chunk *c;
@ -712,6 +712,8 @@ static int cgi_write_request(server *srv, handler_ctx *hctx, int fd) {
}
}
server * const srv = con->srv;
if (cq->bytes_out == (off_t)con->request.content_length && !hctx->conf.upgrade) {
/* sent all request body input */
/* close connection to the cgi-script */
@ -749,15 +751,15 @@ static int cgi_write_request(server *srv, handler_ctx *hctx, int fd) {
return 0;
}
static struct stat * cgi_stat(server *srv, connection *con, buffer *path) {
static struct stat * cgi_stat(connection *con, buffer *path) {
/* CGI might be executable even if it is not readable */
stat_cache_entry *sce;
return (HANDLER_ERROR != stat_cache_get_entry(srv, con, path, &sce))
return (HANDLER_ERROR != stat_cache_get_entry(con, path, &sce))
? &sce->st
: NULL;
}
static int cgi_create_env(server *srv, connection *con, plugin_data *p, handler_ctx *hctx, buffer *cgi_handler) {
static int cgi_create_env(connection *con, plugin_data *p, handler_ctx *hctx, buffer *cgi_handler) {
char *args[3];
int to_cgi_fds[2];
int from_cgi_fds[2];
@ -765,7 +767,7 @@ static int cgi_create_env(server *srv, connection *con, plugin_data *p, handler_
UNUSED(p);
if (!buffer_string_is_empty(cgi_handler)) {
if (NULL == cgi_stat(srv, con, cgi_handler)) {
if (NULL == cgi_stat(con, cgi_handler)) {
log_perror(con->conf.errh, __FILE__, __LINE__,
"stat for cgi-handler %s", cgi_handler->ptr);
return -1;
@ -853,6 +855,8 @@ static int cgi_create_env(server *srv, connection *con, plugin_data *p, handler_
hctx->fd = from_cgi_fds[0];
server * const srv = con->srv;
++srv->cur_fds;
cgi_pid_add(p, hctx->pid, hctx);
@ -868,7 +872,7 @@ static int cgi_create_env(server *srv, connection *con, plugin_data *p, handler_
return -1;
}
if (0 != cgi_write_request(srv, hctx, to_cgi_fds[1])) {
if (0 != cgi_write_request(hctx, to_cgi_fds[1])) {
close(to_cgi_fds[1]);
cgi_connection_close(srv, hctx);
return -1;
@ -903,7 +907,7 @@ URIHANDLER_FUNC(cgi_is_handled) {
ds = (data_string *)array_match_key_suffix(p->conf.cgi, con->physical.path);
if (NULL == ds) return HANDLER_GO_ON;
st = cgi_stat(srv, con, con->physical.path);
st = cgi_stat(con, con->physical.path);
if (NULL == st) return HANDLER_GO_ON;
if (!S_ISREG(st->st_mode)) return HANDLER_GO_ON;
@ -940,15 +944,15 @@ URIHANDLER_FUNC(cgi_is_handled) {
* - HANDLER_WAIT_FOR_EVENT: waiting for response
*/
SUBREQUEST_FUNC(mod_cgi_handle_subrequest) {
plugin_data *p = p_d;
handler_ctx *hctx = con->plugin_ctx[p->id];
chunkqueue *cq = con->request_content_queue;
plugin_data * const p = p_d;
handler_ctx * const hctx = con->plugin_ctx[p->id];
if (con->mode != p->id) return HANDLER_GO_ON;
if (NULL == hctx) return HANDLER_GO_ON;
if ((con->conf.stream_response_body & FDEVENT_STREAM_RESPONSE_BUFMIN)
&& con->file_started) {
server * const srv = con->srv;
if (chunkqueue_length(con->write_queue) > 65536 - 4096) {
fdevent_fdnode_event_clr(srv->ev,hctx->fdn,FDEVENT_IN);
} else if (!(fdevent_fdnode_interest(hctx->fdn) & FDEVENT_IN)) {
@ -959,6 +963,8 @@ SUBREQUEST_FUNC(mod_cgi_handle_subrequest) {
}
}
chunkqueue * const cq = con->request_content_queue;
if (cq->bytes_in != (off_t)con->request.content_length) {
/*(64k - 4k to attempt to avoid temporary files
* in conjunction with FDEVENT_STREAM_REQUEST_BUFMIN)*/
@ -967,7 +973,7 @@ SUBREQUEST_FUNC(mod_cgi_handle_subrequest) {
con->conf.stream_request_body &= ~FDEVENT_STREAM_REQUEST_POLLIN;
if (-1 != hctx->fd) return HANDLER_WAIT_FOR_EVENT;
} else {
handler_t r = connection_handle_read_post_state(srv, con);
handler_t r = connection_handle_read_post_state(con);
if (!chunkqueue_is_empty(cq)) {
if (fdevent_fdnode_interest(hctx->fdntocgi) & FDEVENT_OUT) {
return (r == HANDLER_GO_ON) ? HANDLER_WAIT_FOR_EVENT : r;
@ -986,15 +992,15 @@ SUBREQUEST_FUNC(mod_cgi_handle_subrequest) {
}
if (-1 == hctx->fd) {
if (cgi_create_env(srv, con, p, hctx, hctx->cgi_handler)) {
if (cgi_create_env(con, p, hctx, hctx->cgi_handler)) {
con->http_status = 500;
con->mode = DIRECT;
return HANDLER_FINISHED;
}
} else if (!chunkqueue_is_empty(con->request_content_queue)) {
if (0 != cgi_write_request(srv, hctx, hctx->fdtocgi)) {
cgi_connection_close(srv, hctx);
if (0 != cgi_write_request(hctx, hctx->fdtocgi)) {
cgi_connection_close(con->srv, hctx);
return HANDLER_ERROR;
}
}

2
src/mod_cml.c

@ -208,7 +208,6 @@ static int cache_call_lua(connection *con, plugin_data *p, const buffer *cml_fil
URIHANDLER_FUNC(mod_cml_power_magnet) {
plugin_data *p = p_d;
UNUSED(srv);
mod_cml_patch_config(con, p);
@ -261,7 +260,6 @@ URIHANDLER_FUNC(mod_cml_power_magnet) {
URIHANDLER_FUNC(mod_cml_is_handled) {
plugin_data *p = p_d;
UNUSED(srv);
if (buffer_string_is_empty(con->physical.path)) return HANDLER_ERROR;

50
src/mod_compress.c

@ -485,7 +485,7 @@ static void mod_compress_note_ratio(connection *con, off_t in, off_t out) {
http_header_env_set(con, CONST_STR_LEN("ratio"), ratio, strlen(ratio));
}
static int deflate_file_to_file(server *srv, connection *con, plugin_data *p, int ifd, buffer *fn, stat_cache_entry *sce, int type) {
static int deflate_file_to_file(connection *con, plugin_data *p, int ifd, buffer *fn, stat_cache_entry *sce, int type) {
int ofd;
int ret;
#ifdef USE_MMAP
@ -535,7 +535,7 @@ static int deflate_file_to_file(server *srv, connection *con, plugin_data *p, in
buffer_append_string_buffer(p->ofn, sce->etag);
if (HANDLER_ERROR != stat_cache_get_entry(srv, con, p->ofn, &sce_ofn)) {
if (HANDLER_ERROR != stat_cache_get_entry(con, p->ofn, &sce_ofn)) {
if (0 == sce->st.st_size) return -1; /* cache file being created */
/* cache-entry exists */
#if 0
@ -546,7 +546,7 @@ static int deflate_file_to_file(server *srv, connection *con, plugin_data *p, in
return 0;
}
if (0.0 < p->conf.max_loadavg && p->conf.max_loadavg < srv->loadavg[0]) {
if (0.0 < p->conf.max_loadavg && p->conf.max_loadavg < con->srv->loadavg[0]) {
return -1;
}
@ -675,7 +675,7 @@ static int deflate_file_to_file(server *srv, connection *con, plugin_data *p, in
return 0;
}
static int deflate_file_to_buffer(server *srv, connection *con, plugin_data *p, int ifd, buffer *fn, stat_cache_entry *sce, int type) {
static int deflate_file_to_buffer(connection *con, plugin_data *p, int ifd, buffer *fn, stat_cache_entry *sce, int type) {
int ret = -1;
#ifdef USE_MMAP
volatile int mapped = 0;/* quiet warning: might be clobbered by 'longjmp' */
@ -692,7 +692,7 @@ static int deflate_file_to_buffer(server *srv, connection *con, plugin_data *p,
if (sce->st.st_size > 128 * 1024 * 1024) return -1;
if (0.0 < p->conf.max_loadavg && p->conf.max_loadavg < srv->loadavg[0]) {
if (0.0 < p->conf.max_loadavg && p->conf.max_loadavg < con->srv->loadavg[0]) {
return -1;
}
@ -788,7 +788,7 @@ static int mod_compress_contains_encoding(const char *headervalue, const char *e
PHYSICALPATH_FUNC(mod_compress_physical) {
plugin_data *p = p_d;
size_t m;
uint32_t m;
stat_cache_entry *sce = NULL;
const buffer *mtime = NULL;
buffer *content_type;
@ -816,7 +816,7 @@ PHYSICALPATH_FUNC(mod_compress_physical) {
"-- handling file as static file");
}
if (HANDLER_ERROR == stat_cache_get_entry(srv, con, con->physical.path, &sce)) {
if (HANDLER_ERROR == stat_cache_get_entry(con, con->physical.path, &sce)) {
con->http_status = 403;
log_error(con->conf.errh, __FILE__, __LINE__,
"not a regular file: %s -> %s",