[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r13600: Count sockets returned from socketpair() too. This is probab (in tor/trunk: . src/common src/or)



Author: nickm
Date: 2008-02-19 18:46:08 -0500 (Tue, 19 Feb 2008)
New Revision: 13600

Modified:
   tor/trunk/
   tor/trunk/src/common/compat.c
   tor/trunk/src/or/connection.c
Log:
 r18233@catbus:  nickm | 2008-02-19 18:46:07 -0500
 Count sockets returned from socketpair() too.  This is probably not the socket counting bug.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r18233] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/src/common/compat.c
===================================================================
--- tor/trunk/src/common/compat.c	2008-02-19 23:33:02 UTC (rev 13599)
+++ tor/trunk/src/common/compat.c	2008-02-19 23:46:08 UTC (rev 13600)
@@ -637,6 +637,16 @@
 #if defined(HAVE_SOCKETPAIR) && !defined(MS_WINDOWS)
   int r;
   r = socketpair(family, type, protocol, fd);
+  if (r == 0) {
+    if (fd[0] >= 0) {
+      ++n_sockets_open;
+      mark_socket_open(fd[0]);
+    }
+    if (fd[1] >= 0) {
+      ++n_sockets_open;
+      mark_socket_open(fd[1]);
+    }
+  }
   return r < 0 ? -errno : r;
 #elif defined(USE_BSOCKETS)
   return bsocketpair(family, type, protocol, fd);

Modified: tor/trunk/src/or/connection.c
===================================================================
--- tor/trunk/src/or/connection.c	2008-02-19 23:33:02 UTC (rev 13599)
+++ tor/trunk/src/or/connection.c	2008-02-19 23:46:08 UTC (rev 13600)
@@ -366,6 +366,7 @@
   if (conn->s >= 0) {
     log_debug(LD_NET,"closing fd %d.",conn->s);
     tor_close_socket(conn->s);
+    conn->s = -1;
   }
 
   if (conn->type == CONN_TYPE_OR &&