[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] rotate dns and cpu workers if the controller changes option...
Update of /home2/or/cvsroot/tor/src/or
In directory moria:/home/arma/work/onion/cvs/tor/src/or
Modified Files:
config.c control.c cpuworker.c dns.c main.c or.h
Log Message:
rotate dns and cpu workers if the controller changes options that
will affect them.
Index: config.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/config.c,v
retrieving revision 1.391
retrieving revision 1.392
diff -u -d -r1.391 -r1.392
--- config.c 15 Aug 2005 10:30:45 -0000 1.391
+++ config.c 15 Aug 2005 23:46:17 -0000 1.392
@@ -1978,6 +1978,26 @@
return 0;
}
+/** Return 1 if any option in <b>lines</b> will require us to rotate
+ * the cpu and dns workers; else return 0. */
+int
+options_transition_affects_workers(config_line_t *lines)
+{
+ config_line_t *p;
+ config_var_t *var;
+ for (p = lines; p; p = p->next) {
+ var = config_find_option(&options_format, p->key);
+ if (!var) continue;
+ if (!strcasecmp(var->name, "datadirectory") ||
+ !strcasecmp(var->name, "log") ||
+ !strcasecmp(var->name, "numcpus") ||
+ !strcasecmp(var->name, "orport") ||
+ !strcasecmp(var->name, "safelogging"))
+ return 1;
+ }
+ return 0;
+}
+
#ifdef MS_WINDOWS
/** Return the directory on windows where we expect to find our application
* data. */
Index: control.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/control.c,v
retrieving revision 1.122
retrieving revision 1.123
diff -u -d -r1.122 -r1.123
--- control.c 15 Aug 2005 09:25:36 -0000 1.122
+++ control.c 15 Aug 2005 23:46:17 -0000 1.123
@@ -681,11 +681,16 @@
return 0;
}
- config_free_lines(lines);
if (options_act() < 0) { /* acting on them failed. die. */
log_fn(LOG_ERR,"Acting on config options left us in a broken state. Dying.");
exit(1);
}
+ if (options_transition_affects_workers(lines)) {
+ log_fn(LOG_INFO,"Worker-related options changed. Rotating workers.");
+ cpuworkers_rotate();
+ dnsworkers_rotate();
+ }
+ config_free_lines(lines);
send_control_done(conn);
return 0;
}
Index: cpuworker.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/cpuworker.c,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -d -r1.85 -r1.86
--- cpuworker.c 15 Aug 2005 10:27:37 -0000 1.85
+++ cpuworker.c 15 Aug 2005 23:46:18 -0000 1.86
@@ -100,7 +100,8 @@
--num_cpuworkers;
}
last_rotation_time = time(NULL);
- spawn_enough_cpuworkers();
+ if (server_mode(get_options()))
+ spawn_enough_cpuworkers();
}
/** If the cpuworker closes the connection,
Index: dns.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/dns.c,v
retrieving revision 1.164
retrieving revision 1.165
diff -u -d -r1.164 -r1.165
--- dns.c 15 Aug 2005 10:27:37 -0000 1.164
+++ dns.c 15 Aug 2005 23:46:18 -0000 1.165
@@ -102,6 +102,7 @@
dns_init(void)
{
init_cache_tree();
+ dnsworkers_rotate();
}
/** Helper: free storage held by an entry in the DNS cache. */
@@ -722,7 +723,8 @@
num_dnsworkers--;
}
last_rotation_time = time(NULL);
- spawn_enough_dnsworkers();
+ if (server_mode(get_options()))
+ spawn_enough_dnsworkers();
}
/** Implementation for DNS workers; this code runs in a separate
Index: main.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/main.c,v
retrieving revision 1.534
retrieving revision 1.535
diff -u -d -r1.534 -r1.535
--- main.c 15 Aug 2005 10:27:37 -0000 1.534
+++ main.c 15 Aug 2005 23:46:18 -0000 1.535
@@ -957,11 +957,7 @@
{
int loop_result;
- dns_init(); /* initialize the dns resolve tree */
- /* only spawn dns handlers if we're a router */
- if (server_mode(get_options())) {
- dnsworkers_rotate();
- }
+ dns_init(); /* initialize dns resolve tree, spawn workers if needed */
handle_signals(1);
Index: or.h
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.646
retrieving revision 1.647
diff -u -d -r1.646 -r1.647
--- or.h 15 Aug 2005 09:17:47 -0000 1.646
+++ or.h 15 Aug 2005 23:46:18 -0000 1.647
@@ -1361,6 +1361,7 @@
int options_trial_assign(config_line_t *list, int reset);
int resolve_my_address(or_options_t *options, uint32_t *addr);
void options_init(or_options_t *options);
+int options_transition_affects_workers(config_line_t *lines);
int options_init_from_torrc(int argc, char **argv);
int options_init_logs(or_options_t *options, int validate_only);
int config_parse_addr_policy(config_line_t *cfg,