Browse Source

new config option SocksTimeout: How long do we let a socks connection
wait unattached before we fail it?

Use this value for controller socks timeout, for normal socks
timeout, and for hidden-service socks timeout.


svn:r6217

Roger Dingledine 19 years ago
parent
commit
28fafb9022
4 changed files with 7 additions and 7 deletions
  1. 1 4
      src/or/circuituse.c
  2. 1 0
      src/or/config.c
  3. 3 3
      src/or/connection_edge.c
  4. 2 0
      src/or/or.h

+ 1 - 4
src/or/circuituse.c

@@ -13,9 +13,6 @@ const char circuituse_c_id[] =
 
 #include "or.h"
 
-/** Longest time to wait for a circuit before closing an AP connection */
-#define CONN_AP_MAX_ATTACH_DELAY 59
-
 /********* START VARIABLES **********/
 
 extern circuit_t *global_circuitlist; /* from circuitlist.c */
@@ -1154,7 +1151,7 @@ connection_ap_handshake_attach_circuit(connection_t *conn)
   tor_assert(conn->socks_request);
 
   conn_age = time(NULL) - conn->timestamp_created;
-  if (conn_age > CONN_AP_MAX_ATTACH_DELAY) {
+  if (conn_age > get_options()->SocksTimeout) {
     log_notice(LD_APP,
                "Tried for %d seconds to get a connection to %s:%d. Giving up.",
                conn_age, safe_str(conn->socks_request->address),

+ 1 - 0
src/or/config.c

@@ -223,6 +223,7 @@ static config_var_t _option_vars[] = {
   VAR("SocksListenAddress",  LINELIST, SocksListenAddress,   NULL),
   VAR("SocksPolicy",         LINELIST, SocksPolicy,          NULL),
   VAR("SocksPort",           UINT,     SocksPort,            "9050"),
+  VAR("SocksTimeout",        INTERVAL, SocksTimeout,         "2 minutes"),
   /* if StatusFetchPeriod is 0, see get_status_fetch_period() in main.c */
   VAR("StatusFetchPeriod",   INTERVAL, StatusFetchPeriod,    "0 seconds"),
   VAR("StrictEntryNodes",    BOOL,     StrictEntryNodes,     "0"),

+ 3 - 3
src/or/connection_edge.c

@@ -314,7 +314,7 @@ connection_edge_finished_connecting(connection_t *conn)
  * connection_ap_handshake_attach_circuit() to attach to a new circuit (if
  * available) or launch a new one.
  *
- * For rendezvous streams, simply give up after 45 seconds (with no
+ * For rendezvous streams, simply give up after SocksTimeout seconds (with no
  * retry attempt).
  */
 void
@@ -335,7 +335,7 @@ connection_ap_expire_beginning(void)
     if (conn->type != CONN_TYPE_AP)
       continue;
     if (conn->state == AP_CONN_STATE_CONTROLLER_WAIT) {
-      if (now - conn->timestamp_lastread >= 120) {
+      if (now - conn->timestamp_lastread >= options->SocksTimeout) {
         log_notice(LD_APP, "Closing unattached stream.");
         connection_mark_unattached_ap(conn, END_STREAM_REASON_TIMEOUT);
       }
@@ -355,7 +355,7 @@ connection_ap_expire_beginning(void)
       continue;
     }
     if (circ->purpose == CIRCUIT_PURPOSE_C_REND_JOINED) {
-      if (now - conn->timestamp_lastread > 45) {
+      if (now - conn->timestamp_lastread > options->SocksTimeout) {
         log_notice(LD_REND,
                    "Rend stream is %d seconds late. Giving up on address"
                    " '%s.onion'.",

+ 2 - 0
src/or/or.h

@@ -1315,6 +1315,8 @@ typedef struct {
   int StatusFetchPeriod; /**< How often do we fetch running-routers lists? */
   int KeepalivePeriod; /**< How often do we send padding cells to keep
                         * connections alive? */
+  int SocksTimeout; /**< How long do we let a socks connection wait
+                     * unattached before we fail it? */
   int MaxOnionsPending; /**< How many circuit CREATE requests do we allow
                          * to wait simultaneously before we start dropping
                          * them? */