summaryrefslogtreecommitdiff
path: root/src/feature/control
diff options
context:
space:
mode:
authorTaylor Yu <catalyst@torproject.org>2018-12-16 17:01:25 -0600
committerTaylor Yu <catalyst@torproject.org>2018-12-20 18:46:17 -0600
commita0b4fa1f167f9b013ee1a8326e325ec3f97e4700 (patch)
tree23af519fc5dcd46d597776dea0ec9556aa9e3eab /src/feature/control
parent271b50f54abac7af44e3e54589ff965d3cdac816 (diff)
downloadtor-a0b4fa1f167f9b013ee1a8326e325ec3f97e4700.tar.gz
tor-a0b4fa1f167f9b013ee1a8326e325ec3f97e4700.zip
Add origin circuit event pubsub system
Add a publish-subscribe subsystem to publish messages about changes to origin circuits. Functions in circuitbuild.c and circuitlist.c publish messages to this subsystem. Move circuit event constants out of control.h so that subscribers don't have to include all of control.h to take actions based on messages they receive. Part of ticket 27167.
Diffstat (limited to 'src/feature/control')
-rw-r--r--src/feature/control/control.c5
-rw-r--r--src/feature/control/control.h10
2 files changed, 5 insertions, 10 deletions
diff --git a/src/feature/control/control.c b/src/feature/control/control.c
index 4ef550c919..da62c94981 100644
--- a/src/feature/control/control.c
+++ b/src/feature/control/control.c
@@ -34,6 +34,7 @@
**/
#define CONTROL_PRIVATE
+#define OCIRC_EVENT_PRIVATE
#include "core/or/or.h"
#include "app/config/config.h"
@@ -50,6 +51,7 @@
#include "core/or/command.h"
#include "core/or/connection_edge.h"
#include "core/or/connection_or.h"
+#include "core/or/ocirc_event.h"
#include "core/or/policies.h"
#include "core/or/reasons.h"
#include "core/or/versions.h"
@@ -3749,7 +3751,7 @@ handle_control_extendcircuit(control_connection_t *conn, uint32_t len,
connection_printf_to_buf(conn, "250 EXTENDED %lu\r\n",
(unsigned long)circ->global_identifier);
if (zero_circ) /* send a 'launched' event, for completeness */
- control_event_circuit_status(circ, CIRC_EVENT_LAUNCHED, 0);
+ circuit_event_status(circ, CIRC_EVENT_LAUNCHED, 0);
done:
SMARTLIST_FOREACH(router_nicknames, char *, n, tor_free(n));
smartlist_free(router_nicknames);
@@ -5625,6 +5627,7 @@ control_event_circuit_status(origin_circuit_t *circ, circuit_status_event_t tp,
{
const char *status;
char reasons[64] = "";
+
if (!EVENT_IS_INTERESTING(EVENT_CIRCUIT_STATUS))
return 0;
tor_assert(circ);
diff --git a/src/feature/control/control.h b/src/feature/control/control.h
index d3245fcaf1..68c9a6bed1 100644
--- a/src/feature/control/control.h
+++ b/src/feature/control/control.h
@@ -12,15 +12,7 @@
#ifndef TOR_CONTROL_H
#define TOR_CONTROL_H
-/** Used to indicate the type of a circuit event passed to the controller.
- * The various types are defined in control-spec.txt */
-typedef enum circuit_status_event_t {
- CIRC_EVENT_LAUNCHED = 0,
- CIRC_EVENT_BUILT = 1,
- CIRC_EVENT_EXTENDED = 2,
- CIRC_EVENT_FAILED = 3,
- CIRC_EVENT_CLOSED = 4,
-} circuit_status_event_t;
+#include "core/or/ocirc_event.h"
/** Used to indicate the type of a CIRC_MINOR event passed to the controller.
* The various types are defined in control-spec.txt . */