aboutsummaryrefslogtreecommitdiff
path: root/src/feature
diff options
context:
space:
mode:
authorteor <teor@torproject.org>2019-12-01 17:53:06 +1000
committerteor <teor@torproject.org>2019-12-01 17:53:06 +1000
commit96e620caaf11909bce704f3c55187a139595a8e9 (patch)
tree59018867c2903718277cc981b687f2639a5707b8 /src/feature
parent68a00c4951666b7658064f2547739d280f912398 (diff)
parent41a3930129cac293e958ccb43bcddf82a9643e29 (diff)
downloadtor-96e620caaf11909bce704f3c55187a139595a8e9.tar.gz
tor-96e620caaf11909bce704f3c55187a139595a8e9.zip
Merge remote-tracking branch 'tor-github/pr/1574'
Diffstat (limited to 'src/feature')
-rw-r--r--src/feature/control/control_events.c29
-rw-r--r--src/feature/control/control_events.h7
2 files changed, 17 insertions, 19 deletions
diff --git a/src/feature/control/control_events.c b/src/feature/control/control_events.c
index f88bcfdb9f..ea07a896d4 100644
--- a/src/feature/control/control_events.c
+++ b/src/feature/control/control_events.c
@@ -38,6 +38,7 @@
#include "core/or/origin_circuit_st.h"
#include "lib/evloop/compat_libevent.h"
+#include "lib/encoding/confline.h"
static void flush_queued_events_cb(mainloop_event_t *event, void *arg);
static void control_get_bytes_rw_last_sec(uint64_t *r, uint64_t *w);
@@ -1770,27 +1771,24 @@ control_event_guard(const char *nickname, const char *digest,
}
/** Called when a configuration option changes. This is generally triggered
- * by SETCONF requests and RELOAD/SIGHUP signals. The <b>elements</b> is
- * a smartlist_t containing (key, value, ...) pairs in sequence.
- * <b>value</b> can be NULL. */
-int
-control_event_conf_changed(const smartlist_t *elements)
+ * by SETCONF requests and RELOAD/SIGHUP signals. The <b>changes</b> are
+ * a linked list of configuration key-values.
+ * <b>changes</b> can be NULL, meaning "no changes".
+ */
+void
+control_event_conf_changed(const config_line_t *changes)
{
- int i;
char *result;
smartlist_t *lines;
- if (!EVENT_IS_INTERESTING(EVENT_CONF_CHANGED) ||
- smartlist_len(elements) == 0) {
- return 0;
+ if (!EVENT_IS_INTERESTING(EVENT_CONF_CHANGED) || !changes) {
+ return;
}
lines = smartlist_new();
- for (i = 0; i < smartlist_len(elements); i += 2) {
- char *k = smartlist_get(elements, i);
- char *v = smartlist_get(elements, i+1);
- if (v == NULL) {
- smartlist_add_asprintf(lines, "650-%s", k);
+ for (const config_line_t *line = changes; line; line = line->next) {
+ if (line->value == NULL) {
+ smartlist_add_asprintf(lines, "650-%s", line->key);
} else {
- smartlist_add_asprintf(lines, "650-%s=%s", k, v);
+ smartlist_add_asprintf(lines, "650-%s=%s", line->key, line->value);
}
}
result = smartlist_join_strings(lines, "\r\n", 0, NULL);
@@ -1799,7 +1797,6 @@ control_event_conf_changed(const smartlist_t *elements)
tor_free(result);
SMARTLIST_FOREACH(lines, char *, cp, tor_free(cp));
smartlist_free(lines);
- return 0;
}
/** We just generated a new summary of which countries we've seen clients
diff --git a/src/feature/control/control_events.h b/src/feature/control/control_events.h
index 34986fdb89..edb0e90cd9 100644
--- a/src/feature/control/control_events.h
+++ b/src/feature/control/control_events.h
@@ -13,6 +13,9 @@
#define TOR_CONTROL_EVENTS_H
#include "core/or/ocirc_event.h"
+#include "core/or/orconn_event.h"
+
+struct config_line_t;
/** Used to indicate the type of a CIRC_MINOR event passed to the controller.
* The various types are defined in control-spec.txt . */
@@ -21,8 +24,6 @@ typedef enum circuit_status_minor_event_t {
CIRC_MINOR_EVENT_CANNIBALIZED,
} circuit_status_minor_event_t;
-#include "core/or/orconn_event.h"
-
/** Used to indicate the type of a stream event passed to the controller.
* The various types are defined in control-spec.txt */
typedef enum stream_status_event_t {
@@ -157,7 +158,7 @@ int control_event_server_error(const char *format, ...)
int control_event_guard(const char *nickname, const char *digest,
const char *status);
-int control_event_conf_changed(const smartlist_t *elements);
+void control_event_conf_changed(const struct config_line_t *changes);
int control_event_buildtimeout_set(buildtimeout_set_event_t type,
const char *args);
int control_event_signal(uintptr_t signal);