Browse Source

initialize the dns worker cache tree whether or not we start
out as a server.


svn:r4785

Roger Dingledine 19 years ago
parent
commit
10ff723938
4 changed files with 7 additions and 10 deletions
  1. 2 2
      src/or/config.c
  2. 1 2
      src/or/cpuworker.c
  3. 0 3
      src/or/dns.c
  4. 4 3
      src/or/main.c

+ 2 - 2
src/or/config.c

@@ -432,8 +432,8 @@ options_act(void)
     return -1;
   }
 
-  /* Bail out at this point if we're not going to be a server: we want
-   * to not fork, and to log stuff to stderr. */
+  /* Bail out at this point if we're not going to be a client or server:
+   * we want to not fork, and to log stuff to stderr. */
   if (options->command != CMD_RUN_TOR)
     return 0;
 

+ 1 - 2
src/or/cpuworker.c

@@ -46,8 +46,7 @@ static void process_pending_task(connection_t *cpuworker);
 void
 cpu_init(void)
 {
-  last_rotation_time=time(NULL);
-  spawn_enough_cpuworkers();
+  cpuworkers_rotate();
 }
 
 /** Called when we're done sending a request to a cpuworker. */

+ 0 - 3
src/or/dns.c

@@ -102,8 +102,6 @@ void
 dns_init(void)
 {
   init_cache_tree();
-  last_rotation_time=time(NULL);
-  spawn_enough_dnsworkers();
 }
 
 /** Helper: free storage held by an entry in the DNS cache. */
@@ -718,7 +716,6 @@ void
 dnsworkers_rotate(void)
 {
   connection_t *dnsconn;
-  log_fn(LOG_INFO, "Rotating DNS workers.");
   while ((dnsconn = connection_get_by_type_state(CONN_TYPE_DNSWORKER,
                                                  DNSWORKER_STATE_IDLE))) {
     connection_mark_for_close(dnsconn);

+ 4 - 3
src/or/main.c

@@ -934,7 +934,7 @@ do_hup(void)
      * configuration options. */
     cpuworkers_rotate();
     dnsworkers_rotate();
-    /* Rebuild fresh descriptor, but leave old one on failure. */
+    /* Write out a fresh descriptor, but leave old one on failure. */
     router_rebuild_descriptor(1);
     descriptor = router_get_my_descriptor();
     if (!descriptor) {
@@ -957,9 +957,10 @@ do_main_loop(void)
 {
   int loop_result;
 
+  dns_init(); /* initialize the dns resolve tree */
   /* only spawn dns handlers if we're a router */
   if (server_mode(get_options())) {
-    dns_init(); /* initialize the dns resolve tree, and spawn workers */
+    dnsworkers_rotate();
   }
 
   handle_signals(1);
@@ -1750,7 +1751,7 @@ nt_service_install(void)
   if (tor_snprintf(command, len, "\"%s\" --nt-service -f \"%s%storrc\"",
                    szPath,  szDrive, szDir)<0) {
     printf("Failed: tor_snprinf()\n");
-    free(command);
+    tor_free(command);
     return 0;
   }