[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] [tor/master] Make Tor compile with Libevent 1.0 again.



Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Thu, 4 Jun 2009 03:24:53 -0400
Subject: Make Tor compile with Libevent 1.0 again.
Commit: 33b1d714e779a714c2d55e5da09d0e3c682f273a

---
 configure.in                 |    2 +-
 src/common/compat_libevent.c |   13 ++++++++++++-
 src/common/compat_libevent.h |    9 +++++++++
 src/or/main.c                |    2 +-
 4 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/configure.in b/configure.in
index f9a7b03..f1ac836 100644
--- a/configure.in
+++ b/configure.in
@@ -273,7 +273,7 @@ save_CPPFLAGS="$CPPFLAGS"
 LIBS="-levent $TOR_LIB_WS32 $LIBS"
 LDFLAGS="$TOR_LDFLAGS_libevent $LDFLAGS"
 CPPFLAGS="$TOR_CPPFLAGS_libevent $CPPFLAGS"
-AC_CHECK_FUNCS(event_get_version event_get_version_number event_get_method event_set_log_callback evdns_set_outgoing_bind_address)
+AC_CHECK_FUNCS(event_get_version event_get_version_number event_get_method event_set_log_callback evdns_set_outgoing_bind_address event_base_loopexit)
 AC_CHECK_MEMBERS([struct event.min_heap_idx], , ,
 [#include <event.h>
 ])
diff --git a/src/common/compat_libevent.c b/src/common/compat_libevent.c
index ce9f6a0..d9843c9 100644
--- a/src/common/compat_libevent.c
+++ b/src/common/compat_libevent.c
@@ -134,7 +134,6 @@ tor_event_free(struct event *ev)
 /** Global event base for use by the main thread. */
 struct event_base *the_event_base = NULL;
 
-
 /* This is what passes for version detection on OSX.  We set
  * MACOSX_KQUEUE_IS_BROKEN to true iff we're on a version of OSX before
  * 10.4.0 (aka 1040). */
@@ -188,6 +187,18 @@ tor_libevent_get_base(void)
   return the_event_base;
 }
 
+
+#ifndef HAVE_EVENT_BASE_LOOPEXIT
+/* Replacement for event_base_loopexit on some very old versions of Libevent
+   that we are not yet brave enough to deprecate. */
+int
+tor_event_base_loopexit(struct event_base *base, struct timeval *tv)
+{
+  tor_assert(base == the_event_base);
+  return event_loopexit(tv);
+}
+#endif
+
 /** Return the name of the Libevent backend we're using. */
 const char *
 tor_libevent_get_method(void)
diff --git a/src/common/compat_libevent.h b/src/common/compat_libevent.h
index 5482c47..b70f8d3 100644
--- a/src/common/compat_libevent.h
+++ b/src/common/compat_libevent.h
@@ -33,6 +33,15 @@ struct event *tor_evsignal_new(struct event_base * base, int sig,
 void tor_event_free(struct event *ev);
 #endif
 
+/* XXXX022 If we can drop support for Libevent before 1.1, we can
+ * do without this wrapper. */
+#ifdef HAVE_EVENT_BASE_LOOPEXIT
+#define tor_event_base_loopexit event_base_loopexit
+#else
+struct timeval;
+int tor_event_base_loopexit(struct event_base *base, struct timeval *tv);
+#endif
+
 void tor_libevent_initialize(void);
 struct event_base *tor_libevent_get_base(void);
 const char *tor_libevent_get_method(void);
diff --git a/src/or/main.c b/src/or/main.c
index 1b716f9..c808845 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -395,7 +395,7 @@ connection_start_reading_from_linked_conn(connection_t *conn)
        * the end of its run through the current connections and lets us
        * activate read events for linked connections. */
       struct timeval tv = { 0, 0 };
-      event_base_loopexit(tor_libevent_get_base(), &tv);
+      tor_event_base_loopexit(tor_libevent_get_base(), &tv);
     }
   } else {
     tor_assert(smartlist_isin(active_linked_connection_lst, conn));
-- 
1.5.6.5