Keep track of how many requests have been received on a client socket
authorFabian Keil <fk@fabiankeil.de>
Sun, 21 Oct 2012 13:00:06 +0000 (13:00 +0000)
committerFabian Keil <fk@fabiankeil.de>
Sun, 21 Oct 2012 13:00:06 +0000 (13:00 +0000)
jcc.c
project.h

diff --git a/jcc.c b/jcc.c
index 075f23c..b95f245 100644 (file)
--- a/jcc.c
+++ b/jcc.c
@@ -1,4 +1,4 @@
-const char jcc_rcs[] = "$Id: jcc.c,v 1.401 2012/10/21 12:58:03 fabiankeil Exp $";
+const char jcc_rcs[] = "$Id: jcc.c,v 1.402 2012/10/21 12:59:40 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/jcc.c,v $
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/jcc.c,v $
@@ -1301,6 +1301,9 @@ static jb_err receive_client_request(struct client_state *csp)
    struct list header_list;
    struct list *headers = &header_list;
 
    struct list header_list;
    struct list *headers = &header_list;
 
+   /* We don't care if the arriving data is a valid HTTP request or not. */
+   csp->requests_received_total++;
+
    http = csp->http;
 
    memset(buf, 0, sizeof(buf));
    http = csp->http;
 
    memset(buf, 0, sizeof(buf));
@@ -2664,9 +2667,9 @@ static void serve(struct client_state *csp)
          if (((csp->flags & CSP_FLAG_PIPELINED_REQUEST_WAITING) != 0)
             && socket_is_still_alive(csp->cfd))
          {
          if (((csp->flags & CSP_FLAG_PIPELINED_REQUEST_WAITING) != 0)
             && socket_is_still_alive(csp->cfd))
          {
-            log_error(LOG_LEVEL_CONNECT, "A client request has been "
+            log_error(LOG_LEVEL_CONNECT, "Client request %d has been "
                "pipelined on socket %d and the socket is still alive.",
                "pipelined on socket %d and the socket is still alive.",
-               csp->cfd);
+               csp->requests_received_total+1, csp->cfd);
             prepare_csp_for_next_request(csp);
             continue;
          }
             prepare_csp_for_next_request(csp);
             continue;
          }
@@ -2693,7 +2696,8 @@ static void serve(struct client_state *csp)
             && socket_is_still_alive(csp->cfd))
          {
             log_error(LOG_LEVEL_CONNECT,
             && socket_is_still_alive(csp->cfd))
          {
             log_error(LOG_LEVEL_CONNECT,
-               "Client request arrived in time on socket %d.", csp->cfd);
+               "Client request %u arrived in time on socket %d.",
+               csp->requests_received_total+1, csp->cfd);
             prepare_csp_for_next_request(csp);
          }
          else
             prepare_csp_for_next_request(csp);
          }
          else
@@ -2767,10 +2771,10 @@ static void serve(struct client_state *csp)
    {
       log_error(LOG_LEVEL_CONNECT, "Closing client socket %d. "
          "Keep-alive: %u, Socket alive: %u. Data available: %u. "
    {
       log_error(LOG_LEVEL_CONNECT, "Closing client socket %d. "
          "Keep-alive: %u, Socket alive: %u. Data available: %u. "
-         "Configuration file change detected: %u.",
+         "Configuration file change detected: %u. Requests received: %u.",
          csp->cfd, 0 != (csp->flags & CSP_FLAG_CLIENT_CONNECTION_KEEP_ALIVE),
          socket_is_still_alive(csp->cfd), data_is_available(csp->cfd, 0),
          csp->cfd, 0 != (csp->flags & CSP_FLAG_CLIENT_CONNECTION_KEEP_ALIVE),
          socket_is_still_alive(csp->cfd), data_is_available(csp->cfd, 0),
-         config_file_change_detected);
+         config_file_change_detected, csp->requests_received_total);
       drain_and_close_socket(csp->cfd);
    }
 
       drain_and_close_socket(csp->cfd);
    }
 
index 62b9503..4d9bc57 100644 (file)
--- a/project.h
+++ b/project.h
@@ -1,7 +1,7 @@
 #ifndef PROJECT_H_INCLUDED
 #define PROJECT_H_INCLUDED
 /** Version string. */
 #ifndef PROJECT_H_INCLUDED
 #define PROJECT_H_INCLUDED
 /** Version string. */
-#define PROJECT_H_VERSION "$Id: project.h,v 1.188 2012/10/21 12:56:38 fabiankeil Exp $"
+#define PROJECT_H_VERSION "$Id: project.h,v 1.189 2012/10/21 12:58:03 fabiankeil Exp $"
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/project.h,v $
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/project.h,v $
@@ -877,6 +877,9 @@ struct client_state
    /** socket to talk to client (web browser) */
    jb_socket cfd;
 
    /** socket to talk to client (web browser) */
    jb_socket cfd;
 
+   /** Number of requests received on the client socket. */
+   unsigned int requests_received_total;
+
    /** current connection to the server (may go through a proxy) */
    struct reusable_connection server_connection;
 
    /** current connection to the server (may go through a proxy) */
    struct reusable_connection server_connection;