Replace the IOB_RESET() macro with the new function clear_iob()
[privoxy.git] / jbsockets.c
index 97d7335..45b57a9 100644 (file)
@@ -1,4 +1,4 @@
-const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.115 2012/10/12 11:17:48 fabiankeil Exp $";
+const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.117 2012/10/17 18:01:34 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/jbsockets.c,v $
@@ -734,7 +734,7 @@ void drain_and_close_socket(jb_socket fd)
 #endif
       if (0 != shutdown(fd, SHUT_WR))
       {
-         log_error(LOG_LEVEL_ERROR, "Failed to shutdown socket %d %E", fd);
+         log_error(LOG_LEVEL_CONNECT, "Failed to shutdown socket %d: %E", fd);
       }
 #endif
 #define ARBITRARY_DRAIN_LIMIT 10000
@@ -745,7 +745,7 @@ void drain_and_close_socket(jb_socket fd)
          bytes_drained = read_socket(fd, drainage, sizeof(drainage));
          if (bytes_drained < 0)
          {
-            log_error(LOG_LEVEL_ERROR, "Failed to drain socket %d %E", fd);
+            log_error(LOG_LEVEL_CONNECT, "Failed to drain socket %d: %E", fd);
          }
          else if (bytes_drained > 0)
          {
@@ -1267,6 +1267,18 @@ int accept_connection(struct client_state * csp, jb_socket fds[])
    }
 #endif
 
+#ifdef SO_LINGER
+   {
+      struct linger linger_options;
+      linger_options.l_onoff  = 1;
+      linger_options.l_linger = 5;
+      if (0 != setsockopt(fd, SOL_SOCKET, SO_LINGER, &linger_options, sizeof(linger_options)))
+      {
+         log_error(LOG_LEVEL_ERROR, "Setting SO_LINGER on socket %d failed.", afd);
+      }
+   }
+#endif
+
    csp->cfd = afd;
 #ifdef HAVE_RFC2553
    csp->ip_addr_str = malloc(NI_MAXHOST);