aboutsummaryrefslogtreecommitdiff
path: root/src/core/or/orconn_event.h
diff options
context:
space:
mode:
authorTaylor Yu <catalyst@torproject.org>2019-03-08 09:41:43 -0600
committerDavid Goulet <dgoulet@torproject.org>2019-06-11 11:59:30 -0400
commita8c0f4ddfe3f0a63bd499959c8d921346aa9766e (patch)
tree50793b2860d2ce1532cf23197957c2c22e10aa96 /src/core/or/orconn_event.h
parenta8a0144d1183a3598bffe6c552507c9dcbdcd474 (diff)
downloadtor-a8c0f4ddfe3f0a63bd499959c8d921346aa9766e.tar.gz
tor-a8c0f4ddfe3f0a63bd499959c8d921346aa9766e.zip
Rework orconn tracking to use pubsub
Part of ticket 29976.
Diffstat (limited to 'src/core/or/orconn_event.h')
-rw-r--r--src/core/or/orconn_event.h31
1 files changed, 7 insertions, 24 deletions
diff --git a/src/core/or/orconn_event.h b/src/core/or/orconn_event.h
index 80289d53e6..a3b37d2c3d 100644
--- a/src/core/or/orconn_event.h
+++ b/src/core/or/orconn_event.h
@@ -16,6 +16,8 @@
#ifndef TOR_ORCONN_EVENT_H
#define TOR_ORCONN_EVENT_H
+#include "lib/pubsub/pubsub.h"
+
/**
* @name States of OR connections
*
@@ -62,12 +64,6 @@ typedef enum or_conn_status_event_t {
OR_CONN_EVENT_NEW = 4,
} or_conn_status_event_t;
-/** Discriminant values for orconn event message */
-typedef enum orconn_msgtype_t {
- ORCONN_MSGTYPE_STATE,
- ORCONN_MSGTYPE_STATUS,
-} orconn_msgtype_t;
-
/**
* Message for orconn state update
*
@@ -83,6 +79,8 @@ typedef struct orconn_state_msg_t {
uint8_t state; /**< new connection state */
} orconn_state_msg_t;
+DECLARE_MESSAGE(orconn_state, orconn_state, orconn_state_msg_t *);
+
/**
* Message for orconn status event
*
@@ -95,26 +93,11 @@ typedef struct orconn_status_msg_t {
int reason; /**< reason */
} orconn_status_msg_t;
-/** Discriminated union for the actual message */
-typedef struct orconn_event_msg_t {
- int type;
- union {
- orconn_state_msg_t state;
- orconn_status_msg_t status;
- } u;
-} orconn_event_msg_t;
-
-/**
- * Receiver function pointer for OR subscribers
- *
- * This function gets called synchronously by the publisher.
- **/
-typedef void (*orconn_event_rcvr_t)(const orconn_event_msg_t *);
-
-void orconn_event_subscribe(orconn_event_rcvr_t);
+DECLARE_MESSAGE(orconn_status, orconn_status, orconn_status_msg_t *);
#ifdef ORCONN_EVENT_PRIVATE
-void orconn_event_publish(const orconn_event_msg_t *);
+void orconn_state_publish(orconn_state_msg_t *);
+void orconn_status_publish(orconn_status_msg_t *);
#endif
#endif /* defined(TOR_ORCONN_EVENT_H) */