Browse Source

Starting the channel TLS listener when tor starts

Removing the lazy initialization pattern.
Steven Engler 4 years ago
parent
commit
ea890b6741
2 changed files with 5 additions and 4 deletions
  1. 4 0
      src/app/main/main.c
  2. 1 4
      src/core/or/connection_or.c

+ 4 - 0
src/app/main/main.c

@@ -82,6 +82,7 @@
 #include "core/or/or_connection_st.h"
 #include "core/or/port_cfg_st.h"
 #include "core/or/scheduler.h"
+#include "core/or/channeltls.h"
 
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
@@ -1137,6 +1138,9 @@ run_tor_main_loop(void)
   initialize_mainloop_events();
   scheduler_attach_mainloop();
 
+  channel_tls_start_listener();
+  command_setup_listener(channel_tls_get_listener());
+
   /* load the private keys, if we're supposed to have them, and set up the
    * TLS context. */
   if (! client_identity_key_is_set()) {

+ 1 - 4
src/core/or/connection_or.c

@@ -1670,10 +1670,7 @@ connection_tls_start_handshake,(or_connection_t *conn, int receiving))
     /* It shouldn't already be set */
     tor_assert(!(conn->chan));
     chan_listener = channel_tls_get_listener();
-    if (!chan_listener) {
-      chan_listener = channel_tls_start_listener();
-      command_setup_listener(chan_listener);
-    }
+    tor_assert(chan_listener != NULL);
     chan = channel_tls_handle_incoming(conn);
     channel_listener_queue_incoming(chan_listener, chan);
   }