[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Refactor rend_service_load_keys() into outer loop and loop contents
commit b44693f32d1add5dbf1f42665889b9eac0be6aa3
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Mon Jun 18 12:43:20 2012 -0400
Refactor rend_service_load_keys() into outer loop and loop contents
---
src/or/config.c | 2 +-
src/or/rendservice.c | 33 +++++++++++++++++++++++----------
src/or/rendservice.h | 2 +-
3 files changed, 25 insertions(+), 12 deletions(-)
diff --git a/src/or/config.c b/src/or/config.c
index 598051e..2ea3746 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -1548,7 +1548,7 @@ options_act(const or_options_t *old_options)
monitor_owning_controller_process(options->OwningControllerProcess);
/* reload keys as needed for rendezvous services. */
- if (rend_service_load_keys()<0) {
+ if (rend_service_load_all_keys()<0) {
log_warn(LD_GENERAL,"Error loading rendezvous service keys");
return -1;
}
diff --git a/src/or/rendservice.c b/src/or/rendservice.c
index b257c7a..d140093 100644
--- a/src/or/rendservice.c
+++ b/src/or/rendservice.c
@@ -31,6 +31,8 @@ static rend_intro_point_t *find_intro_point(origin_circuit_t *circ);
static int intro_point_accepted_intro_count(rend_intro_point_t *intro);
static int intro_point_should_expire_now(rend_intro_point_t *intro,
time_t now);
+struct rend_service_t;
+static int rend_service_load_keys(struct rend_service_t *s);
/** Represents the mapping from a virtual port of a rendezvous service to
* a real port on some IP.
@@ -609,10 +611,28 @@ rend_service_update_descriptor(rend_service_t *service)
/** Load and/or generate private keys for all hidden services, possibly
* including keys for client authorization. Return 0 on success, -1 on
- * failure.
- */
+ * failure. */
int
-rend_service_load_keys(void)
+rend_service_load_all_keys(void)
+{
+ SMARTLIST_FOREACH_BEGIN(rend_service_list, rend_service_t *, s) {
+ if (s->private_key)
+ continue;
+ log_info(LD_REND, "Loading hidden-service keys from \"%s\"",
+ s->directory);
+
+ if (rend_service_load_keys(s) < 0)
+ return -1;
+ } SMARTLIST_FOREACH_END(s);
+
+ return 0;
+}
+
+/** Load and/or generate private keys for the hidden service <b>s</b>,
+ * possibly including keys for client authorization. Return 0 on success, -1
+ * on failure. */
+static int
+rend_service_load_keys(rend_service_t *s)
{
int r = 0;
char fname[512];
@@ -621,12 +641,6 @@ rend_service_load_keys(void)
char service_id[16+1];
char extended_desc_cookie[REND_DESC_COOKIE_LEN+1];
- SMARTLIST_FOREACH_BEGIN(rend_service_list, rend_service_t *, s) {
- if (s->private_key)
- continue;
- log_info(LD_REND, "Loading hidden-service keys from \"%s\"",
- s->directory);
-
/* Check/create directory */
if (check_private_dir(s->directory, CPD_CREATE, get_options()->User) < 0)
return -1;
@@ -864,7 +878,6 @@ rend_service_load_keys(void)
memset(desc_cook_out, 0, sizeof(desc_cook_out));
memset(service_id, 0, sizeof(service_id));
memset(extended_desc_cookie, 0, sizeof(extended_desc_cookie));
- } SMARTLIST_FOREACH_END(s);
return r;
}
diff --git a/src/or/rendservice.h b/src/or/rendservice.h
index e584878..baf8d5f 100644
--- a/src/or/rendservice.h
+++ b/src/or/rendservice.h
@@ -14,7 +14,7 @@
int num_rend_services(void);
int rend_config_services(const or_options_t *options, int validate_only);
-int rend_service_load_keys(void);
+int rend_service_load_all_keys(void);
void rend_services_introduce(void);
void rend_consider_services_upload(time_t now);
void rend_hsdir_routers_changed(void);
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits