]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[BUG] fix double-decrement of server connections
authorWilly Tarreau <w@1wt.eu>
Fri, 28 Mar 2008 17:09:38 +0000 (18:09 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 28 Mar 2008 17:19:05 +0000 (18:19 +0100)
If a client does a sudden dirty close (CL_STCLOSE) during a server
connect turn-around, then the number of server connections is
decremented twice. This causes huge problems on the affected
server because when its connection number becomes negative, it
overflows and prevents the server from accepting new connections
due to an apparent saturation.

The fix consists in not decrementing the counter if the server is
in a turn-around state.

src/proto_http.c

index ba79c2b6c3d8268b5e13f471c0c0ec4e66be052f..3f8e0ac88da59cef6b7e218c5dbf454d424ee400 100644 (file)
@@ -2568,11 +2568,14 @@ int process_srv(struct session *t)
                     ((t->req->l == 0 && !(req->flags & BF_WRITE_STATUS)) ||
                      t->be->options & PR_O_ABRT_CLOSE))) { /* give up */
                        tv_eternity(&req->cex);
-                       fd_delete(t->srv_fd);
-                       if (t->srv) {
-                               t->srv->cur_sess--;
-                               if (t->srv->proxy->lbprm.server_drop_conn)
-                                       t->srv->proxy->lbprm.server_drop_conn(t->srv);
+                       if (!(t->flags & SN_CONN_TAR)) {
+                               /* if we are in turn-around, we have already closed the FD */
+                               fd_delete(t->srv_fd);
+                               if (t->srv) {
+                                       t->srv->cur_sess--;
+                                       if (t->srv->proxy->lbprm.server_drop_conn)
+                                               t->srv->proxy->lbprm.server_drop_conn(t->srv);
+                               }
                        }
 
                        /* note that this must not return any error because it would be able to