summaryrefslogtreecommitdiff
path: root/src/or/main.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2009-06-04 14:49:16 -0400
committerNick Mathewson <nickm@torproject.org>2009-06-12 14:27:53 -0400
commit1e709c79d12b2366d4e1c1ea517e313cc29ee3cd (patch)
treebc87d6e2a8da346a061f387174487bdead78b6b0 /src/or/main.c
parent33b1d714e779a714c2d55e5da09d0e3c682f273a (diff)
downloadtor-1e709c79d12b2366d4e1c1ea517e313cc29ee3cd.tar.gz
tor-1e709c79d12b2366d4e1c1ea517e313cc29ee3cd.zip
Isolate Libevent API dependency to just main.c and dns.c in src/or.
The rest of the code was only including event.h so that it could see EV_READ and EV_WRITE, which we were using as part of the connection_watch_events interface for no very good reason.
Diffstat (limited to 'src/or/main.c')
-rw-r--r--src/or/main.c33
1 files changed, 29 insertions, 4 deletions
diff --git a/src/or/main.c b/src/or/main.c
index c808845192..c3dae2ad54 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -18,6 +18,12 @@
#endif
#include "memarea.h"
+#ifdef HAVE_EVENT2_EVENT_H
+#include <event2/event.h>
+#else
+#include <event.h>
+#endif
+
void evdns_shutdown(int);
/********* PROTOTYPES **********/
@@ -140,6 +146,25 @@ connection_add(connection_t *conn)
return 0;
}
+/** Tell libevent that we don't care about <b>conn</b> any more. */
+void
+connection_unregister_events(connection_t *conn)
+{
+ if (conn->read_event) {
+ if (event_del(conn->read_event))
+ log_warn(LD_BUG, "Error removing read event for %d", conn->s);
+ tor_free(conn->read_event);
+ }
+ if (conn->write_event) {
+ if (event_del(conn->write_event))
+ log_warn(LD_BUG, "Error removing write event for %d", conn->s);
+ tor_free(conn->write_event);
+ }
+ if (conn->dns_server_port) {
+ dnsserv_close_listener(conn);
+ }
+}
+
/** Remove the connection from the global list, and remove the
* corresponding poll entry. Calling this function will shift the last
* connection (if any) into the position occupied by conn.
@@ -244,17 +269,17 @@ get_connection_array(void)
}
/** Set the event mask on <b>conn</b> to <b>events</b>. (The event
- * mask is a bitmask whose bits are EV_READ and EV_WRITE.)
+ * mask is a bitmask whose bits are READ_EVENT and WRITE_EVENT)
*/
void
-connection_watch_events(connection_t *conn, short events)
+connection_watch_events(connection_t *conn, watchable_events_t events)
{
- if (events & EV_READ)
+ if (events & READ_EVENT)
connection_start_reading(conn);
else
connection_stop_reading(conn);
- if (events & EV_WRITE)
+ if (events & WRITE_EVENT)
connection_start_writing(conn);
else
connection_stop_writing(conn);