[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 6ba3937..23c619c 100644 (file)
@@ -1357,6 +1357,8 @@ int srv_count_retry_down(struct session *t, int conn_err)
                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,6 +1394,8 @@ 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:
@@ -1399,6 +1403,8 @@ int srv_retryable_connect(struct session *t)
                        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++;
                        /* release other sessions waiting for this server */
@@ -1420,6 +1426,8 @@ int srv_retryable_connect(struct session *t)
                task_wakeup(t->srv->queue_mgt);
 
        if (t->srv)
+               t->srv->cum_sess++;
+       if (t->srv)
                t->srv->failed_conns++;
        t->be->redispatches++;
 
@@ -1456,6 +1464,8 @@ int srv_redispatch_connect(struct session *t)
                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++;
 
@@ -1476,6 +1486,8 @@ int srv_redispatch_connect(struct session *t)
                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 16028ce..c26ba47 100644 (file)
@@ -2508,6 +2508,8 @@ int process_srv(struct session *t)
                                        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.