---- trunk/src/mod_proxy.c (revision 258)
-+++ trunk/src/mod_proxy.c (revision 259)
-@@ -365,8 +365,6 @@
- log_error_write(srv, __FILE__, __LINE__, "sdsd",
- "connect failed:", proxy_fd, strerror(errno), errno);
-
-- proxy_connection_cleanup(srv, hctx);
--
- return -1;
- }
- }
-@@ -615,7 +613,7 @@
- }
-
-
--static int proxy_write_request(server *srv, handler_ctx *hctx) {
-+static handler_t proxy_write_request(server *srv, handler_ctx *hctx) {
- data_proxy *host= hctx->host;
-
- int r;
-@@ -629,7 +627,7 @@
-
- if (-1 == (hctx->fd->fd = socket(r, SOCK_STREAM, 0))) {
- log_error_write(srv, __FILE__, __LINE__, "ss", "socket failed: ", strerror(errno));
-- return -1;
-+ return HANDLER_ERROR;
- }
-
- srv->cur_fds++;
-@@ -639,9 +637,7 @@
- if (-1 == fdevent_fcntl_set(srv->ev, hctx->fd)) {
- log_error_write(srv, __FILE__, __LINE__, "ss", "fcntl failed: ", strerror(errno));
-
-- proxy_connection_cleanup(srv, hctx);
--
-- return -1;
-+ return HANDLER_ERROR;
- }
-
- /* fall through */
-@@ -706,10 +702,10 @@
- break;
- default:
- log_error_write(srv, __FILE__, __LINE__, "s", "(debug) unknown state");
-- return -1;
-+ return HANDLER_ERROR;
- }
-
-- return 0;
-+ return HANDLER_GO_ON;
- }
-
- #define PATCH(x) \
-@@ -779,7 +775,8 @@
- if (con->mode != p->id) return HANDLER_GO_ON;
-
- /* ok, create the request */
-- if (-1 == proxy_write_request(srv, hctx)) {
-+ switch(proxy_write_request(srv, hctx)) {
-+ case HANDLER_ERROR:
- log_error_write(srv, __FILE__, __LINE__, "sbdd", "proxy-server disabled:",
- host->host,
- host->port,
-@@ -789,9 +786,17 @@
- host->usage = -1;
- host->disable_ts = srv->cur_ts;
-
-+ proxy_connection_cleanup(srv, hctx);
-+
- con->mode = DIRECT;
- con->http_status = 503;
- return HANDLER_FINISHED;
-+ case HANDLER_WAIT_FOR_EVENT:
-+ return HANDLER_WAIT_FOR_EVENT;
-+ case HANDLER_WAIT_FOR_FD:
-+ return HANDLER_WAIT_FOR_FD;
-+ default:
-+ break;
- }
-
- if (con->file_started == 1) {