--------------------------------------------------------------------
 ChangeLog for Privoxy
 --------------------------------------------------------------------
+*** Version 3.0.13 (UNRELEASED) ***
+
+- The client socket is kept open until the server socket has
+  been marked as unused. This should increase the chances that
+  the still-open connection will be reused for the client's next
+  request to the same destination.
+
 *** Version 3.0.12 ***
 
 - The socket-timeout option now also works on platforms whose
 
-const char jcc_rcs[] = "$Id: jcc.c,v 1.234 2009/03/18 20:48:42 fabiankeil Exp $";
+const char jcc_rcs[] = "$Id: jcc.c,v 1.235 2009/03/18 21:01:20 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/jcc.c,v $
  *
  * Revisions   :
  *    $Log: jcc.c,v $
+ *    Revision 1.235  2009/03/18 21:01:20  fabiankeil
+ *    Comment fix. Spotted by Roland.
+ *
  *    Revision 1.234  2009/03/18 20:48:42  fabiankeil
  *    If the --no-daemon option is used, enable LOG_LEVEL_INFO
  *    before the config file has been parsed (as we always did).
  * Function    :  serve
  *
  * Description :  This is little more than chat.  We only "serve" to
- *                to close any socket that chat may have opened.
+ *                to close (or remember) any socket that chat may have
+ *                opened.
  *
  * Parameters  :
  *          1  :  csp = Current client state (buffers, headers, etc...)
 #endif /* def AMIGA */
 {
    chat(csp);
-   close_socket(csp->cfd);
 
    if (csp->sfd != JB_INVALID_SOCKET)
    {
        && (csp->flags & CSP_FLAG_SERVER_CONNECTION_KEEP_ALIVE))
       {
          remember_connection(csp->sfd, csp->http, forward_url(csp, csp->http));
+         close_socket(csp->cfd);
+         csp->cfd = JB_INVALID_SOCKET;
          privoxy_mutex_lock(&connection_reuse_mutex);
          if (!monitor_thread_running)
          {
 #endif /* def FEATURE_CONNECTION_KEEP_ALIVE */
    }
 
+   if (csp->cfd != JB_INVALID_SOCKET)
+   {
+      close_socket(csp->cfd);
+   }
+
    csp->flags &= ~CSP_FLAG_ACTIVE;
 
 }