]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[BUG] increment server connections for each connect()
authorWilly Tarreau <w@1wt.eu>
Mon, 10 Dec 2007 14:05:42 +0000 (15:05 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 6 Jan 2008 14:43:38 +0000 (15:43 +0100)
It was abnormal to see more connect errors than connect attempts.
This was caused by the fact that the server's connection count was
not incremented for failed connect() attempts.

Now the per-server connections are correctly incremented for each
connect() attempt. This includes the retries too. The number of
connections effectively served by a server will then be :

   srv->cum_sess - srv->errors - srv->warnings

src/backend.c
src/proto_http.c

index 6ba39373e6402a054827a99993020de5876552bf..23c619c463b99b7cd6ffa9429ea3edaee75e2d55 100644 (file)
@@ -1356,6 +1356,8 @@ int srv_count_retry_down(struct session *t, int conn_err)
                tv_eternity(&t->req->cex);
                srv_close_with_err(t, conn_err, SN_FINST_C,
                                   503, error_message(t, HTTP_ERR_503));
+               if (t->srv)
+                       t->srv->cum_sess++;
                if (t->srv)
                        t->srv->failed_conns++;
                t->be->failed_conns++;
@@ -1392,12 +1394,16 @@ int srv_retryable_connect(struct session *t)
                case SN_ERR_NONE:
                        //fprintf(stderr,"0: c=%d, s=%d\n", c, s);
                        t->srv_state = SV_STCONN;
+                       if (t->srv)
+                               t->srv->cum_sess++;
                        return 1;
            
                case SN_ERR_INTERNAL:
                        tv_eternity(&t->req->cex);
                        srv_close_with_err(t, SN_ERR_INTERNAL, SN_FINST_C,
                                           500, error_message(t, HTTP_ERR_500));
+                       if (t->srv)
+                               t->srv->cum_sess++;
                        if (t->srv)
                                t->srv->failed_conns++;
                        t->be->failed_conns++;
@@ -1419,6 +1425,8 @@ int srv_retryable_connect(struct session *t)
        if (may_dequeue_tasks(t->srv, t->be))
                task_wakeup(t->srv->queue_mgt);
 
+       if (t->srv)
+               t->srv->cum_sess++;
        if (t->srv)
                t->srv->failed_conns++;
        t->be->redispatches++;
@@ -1455,6 +1463,8 @@ int srv_redispatch_connect(struct session *t)
                tv_eternity(&t->req->cex);
                srv_close_with_err(t, SN_ERR_SRVTO, SN_FINST_C,
                                   503, error_message(t, HTTP_ERR_503));
+               if (t->srv)
+                       t->srv->cum_sess++;
                if (t->srv)
                        t->srv->failed_conns++;
                t->be->failed_conns++;
@@ -1475,6 +1485,8 @@ int srv_redispatch_connect(struct session *t)
                tv_eternity(&t->req->cex);
                srv_close_with_err(t, SN_ERR_INTERNAL, SN_FINST_C,
                                   500, error_message(t, HTTP_ERR_500));
+               if (t->srv)
+                       t->srv->cum_sess++;
                if (t->srv)
                        t->srv->failed_conns++;
                t->be->failed_conns++;
index 16028cedafcaf52f812370264488c68b2c84ff46..c26ba477c91f6525ba73a9f91ac6be999ffabc52 100644 (file)
@@ -2507,6 +2507,8 @@ int process_srv(struct session *t)
                                if (may_dequeue_tasks(t->srv, t->be))
                                        task_wakeup(t->srv->queue_mgt);
 
+                               if (t->srv)
+                                       t->srv->cum_sess++;
                                if (t->srv)
                                        t->srv->failed_conns++;
                                t->be->redispatches++;
@@ -2560,8 +2562,6 @@ int process_srv(struct session *t)
                                        tv_eternity(&rep->rex);
                
                                t->srv_state = SV_STDATA;
-                               if (t->srv)
-                                       t->srv->cum_sess++;
                                rep->rlim = rep->data + BUFSIZE; /* no rewrite needed */
 
                                /* if the user wants to log as soon as possible, without counting
@@ -2579,8 +2579,6 @@ int process_srv(struct session *t)
                        }
                        else {
                                t->srv_state = SV_STHEADERS;
-                               if (t->srv)
-                                       t->srv->cum_sess++;
                                rep->rlim = rep->data + BUFSIZE - MAXREWRITE; /* rewrite needed */
                                t->txn.rsp.msg_state = HTTP_MSG_RPBEFORE;
                                /* reset hdr_idx which was already initialized by the request.