Upstream-Status: Submitted [http://redmine.lighttpd.net/issues/1264]
Signed-off-by: Li Xin <lixin.fnst@cn.fujitsu.com>
+
+Update context for 1.4.36.
+
+Signed-off-by: Kai Kang <kai.kang@windriver.com>
---
doc/config/lighttpd.conf | 8 ++
src/mod_cgi.c | 188 ++++++++++++++++++++++++++++++++++++++++++++---
- 2 files changed, 186 insertions(+), 10 deletions(-)
+ 2 files changed, 187 insertions(+), 9 deletions(-)
diff --git a/doc/config/lighttpd.conf b/doc/config/lighttpd.conf
index 60b0ae1..9c101a7 100644
#######################################################################
##
diff --git a/src/mod_cgi.c b/src/mod_cgi.c
-index 734ecee..c51f43c 100644
+index 01b1877..7c67eb5 100644
--- a/src/mod_cgi.c
+++ b/src/mod_cgi.c
@@ -38,6 +38,10 @@
free(hctx);
}
-@@ -152,6 +186,8 @@ SETDEFAULTS_FUNC(mod_fastcgi_set_defaults) {
+@@ -154,6 +188,8 @@ SETDEFAULTS_FUNC(mod_fastcgi_set_defaults) {
config_values_t cv[] = {
{ "cgi.assign", NULL, T_CONFIG_ARRAY, T_CONFIG_SCOPE_CONNECTION }, /* 0 */
{ "cgi.execute-x-only", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 1 */
{ NULL, NULL, T_CONFIG_UNSET, T_CONFIG_SCOPE_UNSET}
};
-@@ -167,9 +203,13 @@ SETDEFAULTS_FUNC(mod_fastcgi_set_defaults) {
+@@ -169,9 +205,13 @@ SETDEFAULTS_FUNC(mod_fastcgi_set_defaults) {
s->cgi = array_init();
s->execute_x_only = 0;
p->config_storage[i] = s;
-@@ -182,6 +222,51 @@ SETDEFAULTS_FUNC(mod_fastcgi_set_defaults) {
+@@ -184,6 +224,51 @@ SETDEFAULTS_FUNC(mod_fastcgi_set_defaults) {
}
static int cgi_pid_add(server *srv, plugin_data *p, pid_t pid) {
int m = -1;
size_t i;
-@@ -228,6 +313,39 @@ static int cgi_pid_del(server *srv, plugin_data *p, pid_t pid) {
+@@ -230,6 +315,39 @@ static int cgi_pid_del(server *srv, plugin_data *p, pid_t pid) {
return 0;
}
static int cgi_response_parse(server *srv, connection *con, plugin_data *p, buffer *in) {
char *ns;
const char *s;
-@@ -378,6 +496,13 @@ static int cgi_demux_response(server *srv, handler_ctx *hctx) {
+@@ -380,6 +498,14 @@ static int cgi_demux_response(server *srv, handler_ctx *hctx) {
+
+ buffer_commit(hctx->response, n);
- hctx->response->ptr[n] = '\0';
- hctx->response->used = n+1;
+#ifdef DEBUG
+ sprintf(msgbuf, "n=%d, bytes_out=%llu, bytes_in=%llu", n,
+ (unsigned long long)con->write_queue->bytes_out,
+ log_error_write(srv, __FILE__, __LINE__, "ss",
+ "(debug) read,", msgbuf);
+#endif
-
++
/* split header from body */
-@@ -502,8 +627,20 @@ static int cgi_demux_response(server *srv, handler_ctx *hctx) {
+ if (con->file_started == 0) {
+@@ -503,7 +629,20 @@ static int cgi_demux_response(server *srv, handler_ctx *hctx) {
}
} else {
- http_chunk_append_mem(srv, con, hctx->response->ptr, hctx->response->used);
+ http_chunk_append_buffer(srv, con, hctx->response);
+#ifdef DEBUG
+ sprintf(msgbuf, "n=%d, bytes_out=%llu, bytes_in=%llu, limit=%llu", n,
+ (unsigned long long)con->write_queue->bytes_out,
+ "ss", "(debug) append,", msgbuf);
+#endif
joblist_append(srv, con);
-- }
++
+ cgi_throttling_control(srv, hctx);
+ if (hctx->throttling) {
+ return FDEVENT_HANDLED_NOT_FINISHED;
+ }
-+ }
+ }
#if 0
- log_error_write(srv, __FILE__, __LINE__, "ddss", con->fd, hctx->fd, connection_get_state(con->state), b->ptr);
-@@ -552,8 +689,9 @@ static handler_t cgi_connection_close(server *srv, handler_ctx *hctx) {
+@@ -553,8 +692,9 @@ static handler_t cgi_connection_close(server *srv, handler_ctx *hctx) {
con->plugin_ctx[p->id] = NULL;
/* is this a good idea ? */
/* if waitpid hasn't been called by response.c yet, do it here */
if (pid) {
/* check if the CGI-script is already gone */
-@@ -1156,7 +1294,8 @@ static int cgi_create_env(server *srv, connection *con, plugin_data *p, buffer *
+@@ -1105,7 +1245,8 @@ static int cgi_create_env(server *srv, connection *con, plugin_data *p, buffer *
con->mode = p->id;
buffer_reset(con->physical.path);
hctx->remote_conn = con;
hctx->plugin_data = p;
-@@ -1165,6 +1304,11 @@ static int cgi_create_env(server *srv, connection *con, plugin_data *p, buffer *
+@@ -1114,6 +1255,11 @@ static int cgi_create_env(server *srv, connection *con, plugin_data *p, buffer *
hctx->fde_ndx = -1;
con->plugin_ctx[p->id] = hctx;
fdevent_register(srv->ev, hctx->fd, cgi_handle_fdevent, hctx);
fdevent_event_set(srv->ev, &(hctx->fde_ndx), hctx->fd, FDEVENT_IN);
-@@ -1179,7 +1323,8 @@ static int cgi_create_env(server *srv, connection *con, plugin_data *p, buffer *
+@@ -1128,7 +1274,8 @@ static int cgi_create_env(server *srv, connection *con, plugin_data *p, buffer *
close(hctx->fd);
con->plugin_ctx[p->id] = NULL;
-@@ -1204,6 +1349,8 @@ static int mod_cgi_patch_connection(server *srv, connection *con, plugin_data *p
+@@ -1153,6 +1300,8 @@ static int mod_cgi_patch_connection(server *srv, connection *con, plugin_data *p
PATCH(cgi);
PATCH(execute_x_only);
/* skip the first, the global context */
for (i = 1; i < srv->config_context->used; i++) {
-@@ -1221,6 +1368,10 @@ static int mod_cgi_patch_connection(server *srv, connection *con, plugin_data *p
+@@ -1170,6 +1319,10 @@ static int mod_cgi_patch_connection(server *srv, connection *con, plugin_data *p
PATCH(cgi);
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("cgi.execute-x-only"))) {
PATCH(execute_x_only);
}
}
}
-@@ -1273,6 +1424,21 @@ URIHANDLER_FUNC(cgi_is_handled) {
+@@ -1222,6 +1375,21 @@ URIHANDLER_FUNC(cgi_is_handled) {
TRIGGER_FUNC(cgi_trigger) {
plugin_data *p = p_d;
size_t ndx;
/* the trigger handle only cares about lonely PID which we have to wait for */
#ifndef __WIN32
-@@ -1381,7 +1547,8 @@ SUBREQUEST_FUNC(mod_cgi_handle_subrequest) {
+@@ -1330,7 +1498,8 @@ SUBREQUEST_FUNC(mod_cgi_handle_subrequest) {
log_error_write(srv, __FILE__, __LINE__, "sds", "cgi close failed ", hctx->fd, strerror(errno));
}
con->plugin_ctx[p->id] = NULL;
-@@ -1413,7 +1580,8 @@ SUBREQUEST_FUNC(mod_cgi_handle_subrequest) {
+@@ -1362,7 +1531,8 @@ SUBREQUEST_FUNC(mod_cgi_handle_subrequest) {
log_error_write(srv, __FILE__, __LINE__, "sds", "cgi close failed ", hctx->fd, strerror(errno));
}
con->plugin_ctx[p->id] = NULL;
return HANDLER_FINISHED;
---
-1.8.4.2
-