From c2e98f63404bed1a08719463774a04a010bba68f Mon Sep 17 00:00:00 2001 From: Narayan Kamath Date: Wed, 13 Sep 2017 13:12:34 +0100 Subject: [PATCH] tombstoned: Fix calls to evconnlistener_new. The order of arguments is wrong - we're passing flags=static_cast(-1) and backlog=LEV_OPT_CLOSE_ON_FREE (which is 2). On versions of libevent prior to 2.1.8, this ends up accidentally setting OPT_LEAVE_SOCKETS_BLOCKING, OPT_CLOSE_ON_EXEC, OPT_REUSABLE and OPT_THREADSAFE and limiting our backlog to two. These unintentional changes are relatively benign; we never make our sockets block, we never exec, we never reuse sockets and the additional locking overhead should be negligible. The backlog of two might be a problem in theory, but there haven't been any reports of issues caused by it. Things get worse on 2.1.8 - that version introduces several new flags, one of which is OPT_DISABLED. This disables the new listener by default, which means that our event loop returns early because it has no active listeners for any of its events. Bug: 64543673 Test: Manual. Change-Id: I9954bc7fe1af761de1a950d935dd2e6ce7e2c5f5 --- debuggerd/tombstoned/tombstoned.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/debuggerd/tombstoned/tombstoned.cpp b/debuggerd/tombstoned/tombstoned.cpp index 93c7fb5b8..1bf8f14d0 100644 --- a/debuggerd/tombstoned/tombstoned.cpp +++ b/debuggerd/tombstoned/tombstoned.cpp @@ -389,8 +389,9 @@ int main(int, char* []) { intercept_manager = new InterceptManager(base, intercept_socket); - evconnlistener* tombstone_listener = evconnlistener_new( - base, crash_accept_cb, CrashQueue::for_tombstones(), -1, LEV_OPT_CLOSE_ON_FREE, crash_socket); + evconnlistener* tombstone_listener = + evconnlistener_new(base, crash_accept_cb, CrashQueue::for_tombstones(), LEV_OPT_CLOSE_ON_FREE, + -1 /* backlog */, crash_socket); if (!tombstone_listener) { LOG(FATAL) << "failed to create evconnlistener for tombstones."; } @@ -402,8 +403,9 @@ int main(int, char* []) { } evutil_make_socket_nonblocking(java_trace_socket); - evconnlistener* java_trace_listener = evconnlistener_new( - base, crash_accept_cb, CrashQueue::for_anrs(), -1, LEV_OPT_CLOSE_ON_FREE, java_trace_socket); + evconnlistener* java_trace_listener = + evconnlistener_new(base, crash_accept_cb, CrashQueue::for_anrs(), LEV_OPT_CLOSE_ON_FREE, + -1 /* backlog */, java_trace_socket); if (!java_trace_listener) { LOG(FATAL) << "failed to create evconnlistener for java traces."; }