]> git.pld-linux.org Git - packages/lighttpd.git/blob - lighttpd-proxy-error-handler.patch
- ticket 101
[packages/lighttpd.git] / lighttpd-proxy-error-handler.patch
1 --- trunk/src/mod_proxy.c       (revision 258)
2 +++ trunk/src/mod_proxy.c       (revision 259)
3 @@ -365,8 +365,6 @@
4                         log_error_write(srv, __FILE__, __LINE__, "sdsd", 
5                                         "connect failed:", proxy_fd, strerror(errno), errno);
6                         
7 -                       proxy_connection_cleanup(srv, hctx);
8 -                       
9                         return -1;
10                 }
11         }
12 @@ -615,7 +613,7 @@
13  }
14  
15  
16 -static int proxy_write_request(server *srv, handler_ctx *hctx) {
17 +static handler_t proxy_write_request(server *srv, handler_ctx *hctx) {
18         data_proxy *host= hctx->host;
19         
20         int r;
21 @@ -629,7 +627,7 @@
22                 
23                 if (-1 == (hctx->fd->fd = socket(r, SOCK_STREAM, 0))) {
24                         log_error_write(srv, __FILE__, __LINE__, "ss", "socket failed: ", strerror(errno));
25 -                       return -1;
26 +                       return HANDLER_ERROR;
27                 }
28                 
29                 srv->cur_fds++;
30 @@ -639,9 +637,7 @@
31                 if (-1 == fdevent_fcntl_set(srv->ev, hctx->fd)) {
32                         log_error_write(srv, __FILE__, __LINE__, "ss", "fcntl failed: ", strerror(errno));
33                         
34 -                       proxy_connection_cleanup(srv, hctx);
35 -                       
36 -                       return -1;
37 +                       return HANDLER_ERROR;
38                 }
39                 
40                 /* fall through */
41 @@ -706,10 +702,10 @@
42                 break;
43         default:
44                 log_error_write(srv, __FILE__, __LINE__, "s", "(debug) unknown state");
45 -               return -1;
46 +               return HANDLER_ERROR;
47         }
48         
49 -       return 0;
50 +       return HANDLER_GO_ON;
51  }
52  
53  #define PATCH(x) \
54 @@ -779,7 +775,8 @@
55         if (con->mode != p->id) return HANDLER_GO_ON;
56         
57         /* ok, create the request */
58 -       if (-1 == proxy_write_request(srv, hctx)) {
59 +       switch(proxy_write_request(srv, hctx)) {
60 +       case HANDLER_ERROR:
61                 log_error_write(srv, __FILE__, __LINE__,  "sbdd", "proxy-server disabled:", 
62                                 host->host,
63                                 host->port,
64 @@ -789,9 +786,17 @@
65                 host->usage = -1;
66                 host->disable_ts = srv->cur_ts;
67                 
68 +               proxy_connection_cleanup(srv, hctx);
69 +               
70                 con->mode = DIRECT;
71                 con->http_status = 503;
72                 return HANDLER_FINISHED;
73 +       case HANDLER_WAIT_FOR_EVENT:
74 +               return HANDLER_WAIT_FOR_EVENT;
75 +       case HANDLER_WAIT_FOR_FD:
76 +               return HANDLER_WAIT_FOR_FD;
77 +       default:
78 +               break;
79         }
80         
81         if (con->file_started == 1) {
This page took 0.046391 seconds and 3 git commands to generate.