Bug #2217 ยป lighttpd-1.4.23-diff.patch
src/mod_cgi.c | ||
---|---|---|
return cgi_connection_close(srv, con->plugin_ctx[p->id]);
|
||
}
|
||
static handler_t cgi_handle_end_of_output(server *srv, connection *con, handler_ctx *hctx) {
|
||
/* check if we still have a unfinished header package which is a body in reality */
|
||
if (con->file_started == 0 &&
|
||
hctx->response_header->used) {
|
||
con->file_started = 1;
|
||
http_chunk_append_mem(srv, con, hctx->response_header->ptr, hctx->response_header->used);
|
||
joblist_append(srv, con);
|
||
}
|
||
if (con->file_finished == 0) {
|
||
http_chunk_append_mem(srv, con, NULL, 0);
|
||
joblist_append(srv, con);
|
||
}
|
||
con->file_finished = 1;
|
||
if (chunkqueue_is_empty(con->write_queue)) {
|
||
/* there is nothing left to write */
|
||
connection_set_state(srv, con, CON_STATE_RESPONSE_END);
|
||
} else {
|
||
/* used the write-handler to finish the request on demand */
|
||
}
|
||
return HANDLER_FINISHED;
|
||
}
|
||
static handler_t cgi_handle_fdevent(void *s, void *ctx, int revents) {
|
||
server *srv = (server *)s;
|
||
... | ... | |
/* perhaps this issue is already handled */
|
||
if (revents & FDEVENT_HUP) {
|
||
/* check if we still have a unfinished header package which is a body in reality */
|
||
if (con->file_started == 0 &&
|
||
hctx->response_header->used) {
|
||
con->file_started = 1;
|
||
http_chunk_append_mem(srv, con, hctx->response_header->ptr, hctx->response_header->used);
|
||
joblist_append(srv, con);
|
||
}
|
||
if (con->file_finished == 0) {
|
||
http_chunk_append_mem(srv, con, NULL, 0);
|
||
joblist_append(srv, con);
|
||
}
|
||
con->file_finished = 1;
|
||
if (chunkqueue_is_empty(con->write_queue)) {
|
||
/* there is nothing left to write */
|
||
connection_set_state(srv, con, CON_STATE_RESPONSE_END);
|
||
} else {
|
||
/* used the write-handler to finish the request on demand */
|
||
}
|
||
/* finish handling any pending response */
|
||
cgi_handle_end_of_output(srv, con, hctx);
|
||
# if 0
|
||
log_error_write(srv, __FILE__, __LINE__, "sddd", "got HUP from cgi", con->fd, hctx->fd, revents);
|
||
... | ... | |
fdevent_event_del(srv->ev, &(hctx->fde_ndx), hctx->fd);
|
||
fdevent_unregister(srv->ev, hctx->fd);
|
||
/* finish handling any pending response */
|
||
cgi_handle_end_of_output(srv, con, hctx);
|
||
if (close(hctx->fd)) {
|
||
log_error_write(srv, __FILE__, __LINE__, "sds", "cgi close failed ", hctx->fd, strerror(errno));
|
||
}
|