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

[tor-commits] [tor/master] Merge remote-tracking branch 'public/bug2850' into maint-0.2.2



commit 919bf6ff3cfb1387f3f9ecf9ce97d8e95e330a05
Merge: 83fe07d aba7bb7
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Mon May 16 11:10:17 2011 -0400

    Merge remote-tracking branch 'public/bug2850' into maint-0.2.2
    
    Fixed a trivial conflict where this and the ControlSocketGroupWritable
    code both added different functions to the same part of connection.c.
    
    Conflicts:
    	src/or/connection.c

 changes/bug2850     |    5 +++++
 src/or/connection.c |   34 +++++++++++++++++++++++-----------
 2 files changed, 28 insertions(+), 11 deletions(-)

diff --cc src/or/connection.c
index b7d6fe4,e90e13f..5054909
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@@ -853,43 -851,25 +853,62 @@@ warn_too_many_conns(void
    }
  }
  
 +#ifdef HAVE_SYS_UN_H
 +/** Check whether we should be willing to open an AF_UNIX socket in
 + * <b>path</b>.  Return 0 if we should go ahead and -1 if we shouldn't. */
 +static int
 +check_location_for_unix_socket(or_options_t *options, const char *path)
 +{
 +  int r = -1;
 +  char *p = tor_strdup(path);
 +  cpd_check_t flags = CPD_CHECK_MODE_ONLY;
 +  if (get_parent_directory(p)<0)
 +    goto done;
 +
 +  if (options->ControlSocketsGroupWritable)
 +    flags |= CPD_GROUP_OK;
 +
 +  if (check_private_dir(p, flags) < 0) {
 +    char *escpath, *escdir;
 +    escpath = esc_for_log(path);
 +    escdir = esc_for_log(p);
 +    log_warn(LD_GENERAL, "Before Tor can create a control socket in %s, the "
 +             "directory %s needs to exist, and to be accessible only by the "
 +             "user%s account that is running Tor.  (On some Unix systems, "
 +             "anybody who can list a socket can conect to it, so Tor is "
 +             "being careful.)", escpath, escdir,
 +             options->ControlSocketsGroupWritable ? " and group" : "");
 +    tor_free(escpath);
 +    tor_free(escdir);
 +    goto done;
 +  }
 +
 +  r = 0;
 + done:
 +  tor_free(p);
 +  return r;
 +}
 +#endif
 +
+ /** Tell the TCP stack that it shouldn't wait for a long time after
+  * <b>sock</b> has closed before reusing its port. */
+ static void
+ make_socket_reuseable(int sock)
+ {
+ #ifdef MS_WINDOWS
+   (void) sock;
+ #else
+   int one=1;
+ 
+   /* REUSEADDR on normal places means you can rebind to the port
+    * right after somebody else has let it go. But REUSEADDR on win32
+    * means you can bind to the port _even when somebody else
+    * already has it bound_. So, don't do that on Win32. */
+   setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void*) &one,
+              (socklen_t)sizeof(one));
+ #endif
+ }
+ 
  /** Bind a new non-blocking socket listening to the socket described
   * by <b>listensockaddr</b>.
   *
@@@ -912,11 -891,7 +931,8 @@@ connection_create_listener(const struc
    }
  
    if (listensockaddr->sa_family == AF_INET) {
 +    tor_addr_t addr;
      int is_tcp = (type != CONN_TYPE_AP_DNS_LISTENER);
- #ifndef MS_WINDOWS
-     int one=1;
- #endif
      if (is_tcp)
        start_reading = 1;
  



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits