Set the timestamp directly after receiving the response headers.
[privoxy.git] / jcc.c
diff --git a/jcc.c b/jcc.c
index ed17ba8..ea6f99d 100644 (file)
--- a/jcc.c
+++ b/jcc.c
@@ -1,4 +1,4 @@
-const char jcc_rcs[] = "$Id: jcc.c,v 1.264 2009/07/07 16:42:26 fabiankeil Exp $";
+const char jcc_rcs[] = "$Id: jcc.c,v 1.266 2009/07/11 14:39:34 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/jcc.c,v $
@@ -1077,6 +1077,8 @@ void save_connection_destination(jb_socket sfd,
 {
    assert(sfd != JB_INVALID_SOCKET);
    assert(NULL != http->host);
+
+   server_connection->sfd = sfd;
    server_connection->host = strdup(http->host);
    if (NULL == server_connection->host)
    {
@@ -1867,6 +1869,16 @@ static void chat(struct client_state *csp)
        */
       if (FD_ISSET(csp->sfd, &rfds))
       {
+#ifdef FEATURE_CONNECTION_KEEP_ALIVE
+         if (!socket_is_still_usable(csp->cfd))
+         {
+            log_error(LOG_LEVEL_CONNECT,
+               "The server still wants to talk, but the client hung up on us.");
+            mark_server_socket_tainted(csp);
+            return;
+         }
+#endif /* def FEATURE_CONNECTION_KEEP_ALIVE */
+
          fflush(NULL);
          len = read_socket(csp->sfd, buf, sizeof(buf) - 1);
 
@@ -2178,6 +2190,8 @@ static void chat(struct client_state *csp)
                return;
             }
 
+            csp->server_connection.timestamp = time(NULL);
+
             /*
              * We have now received the entire server header,
              * filter it and send the result to the client
@@ -2381,9 +2395,7 @@ static void serve(struct client_state *csp)
                "No additional client request received in time.");
             if ((csp->config->feature_flags & RUNTIME_FEATURE_CONNECTION_SHARING))
             {
-               remember_connection(csp->sfd, csp->http,
-                  forward_url(csp, csp->http),
-                  csp->server_connection.keep_alive_timeout);
+               remember_connection(csp, forward_url(csp, csp->http));
                csp->sfd = JB_INVALID_SOCKET;
                close_socket(csp->cfd);
                csp->cfd = JB_INVALID_SOCKET;