$OpenBSD: patch-src_mod_proxy_c,v 1.3 2010/04/09 11:06:22 sthen Exp $ --- src/mod_proxy.c.orig Mon Feb 1 18:28:20 2010 +++ src/mod_proxy.c Wed Apr 7 21:05:00 2010 @@ -349,6 +349,10 @@ static void proxy_connection_close(server *srv, handle srv->cur_fds--; } + if (hctx->host) { + hctx->host->usage--; + } + handler_ctx_free(hctx); con->plugin_ctx[p->id] = NULL; } @@ -848,11 +852,11 @@ static handler_t proxy_write_request(server *srv, hand if (-1 == ret) { /* error on our side */ log_error_write(srv, __FILE__, __LINE__, "ssd", "write failed:", strerror(errno), errno); - return HANDLER_WAIT_FOR_EVENT; + return HANDLER_ERROR; } else if (-2 == ret) { /* remote close */ log_error_write(srv, __FILE__, __LINE__, "ssd", "write failed, remote connection close:", strerror(errno), errno); - return HANDLER_WAIT_FOR_EVENT; + return HANDLER_ERROR; } if (hctx->wb->bytes_out == hctx->wb->bytes_in) { @@ -989,8 +993,6 @@ static handler_t proxy_handle_fdevent(void *s, void *c case 0: break; case 1: - hctx->host->usage--; - /* we are done */ proxy_connection_close(srv, hctx); @@ -1077,8 +1079,11 @@ static handler_t proxy_handle_fdevent(void *s, void *c return HANDLER_FINISHED; } - con->file_finished = 1; + if (!con->file_finished) { + http_chunk_append_mem(srv, con, NULL, 0); + } + con->file_finished = 1; proxy_connection_close(srv, hctx); joblist_append(srv, con); } else if (revents & FDEVENT_ERR) { @@ -1086,6 +1091,7 @@ static handler_t proxy_handle_fdevent(void *s, void *c log_error_write(srv, __FILE__, __LINE__, "sd", "proxy-FDEVENT_ERR, but no HUP", revents); + con->file_finished = 1; joblist_append(srv, con); proxy_connection_close(srv, hctx); }