summaryrefslogtreecommitdiff
path: root/src/common/compat_libevent.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2011-11-14 17:53:45 -0500
committerNick Mathewson <nickm@torproject.org>2011-11-14 17:53:45 -0500
commit0f6c02161793fa1022fe721ed9c1aac3538294b3 (patch)
tree74eee8c1e094e06edab9f4fa3aaffd2b7a165f8a /src/common/compat_libevent.c
parent7363eae13cb8febd85923957de19e2de7c186cea (diff)
downloadtor-0f6c02161793fa1022fe721ed9c1aac3538294b3.tar.gz
tor-0f6c02161793fa1022fe721ed9c1aac3538294b3.zip
Detect failure from event_init() or event_base_new_with_config()
Diffstat (limited to 'src/common/compat_libevent.c')
-rw-r--r--src/common/compat_libevent.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/common/compat_libevent.c b/src/common/compat_libevent.c
index 3e35e093e4..ddb2da68aa 100644
--- a/src/common/compat_libevent.c
+++ b/src/common/compat_libevent.c
@@ -179,6 +179,7 @@ tor_libevent_initialize(void)
#ifdef HAVE_EVENT2_EVENT_H
{
struct event_config *cfg = event_config_new();
+ tor_assert(cfg);
/* In 0.2.2, we don't use locking at all. Telling Libevent not to try to
* turn it on can avoid a needless socketpair() attempt.
@@ -193,6 +194,11 @@ tor_libevent_initialize(void)
the_event_base = event_init();
#endif
+ if (!the_event_base) {
+ log_err(LD_GENERAL, "Unable to initialize Libevent: cannot continue.");
+ exit(1);
+ }
+
#if defined(HAVE_EVENT_GET_VERSION) && defined(HAVE_EVENT_GET_METHOD)
/* Making this a NOTICE for now so we can link bugs to a libevent versions
* or methods better. */