libevent 2.0 compat

This commit is contained in:
Michael Davidsaver
2020-03-20 09:00:20 -07:00
parent 320755ebd5
commit d452e009ce
6 changed files with 6 additions and 4 deletions
+1 -1
View File
@@ -27,7 +27,7 @@ Connection::Connection(const std::shared_ptr<Context::Pvt>& context, const SockA
timeval timo = {30, 0};
bufferevent_set_timeouts(bev.get(), &timo, &timo);
if(bufferevent_socket_connect(bev.get(), &peerAddr->sa, peerAddr.size()))
if(bufferevent_socket_connect(bev.get(), const_cast<sockaddr*>(&peerAddr->sa), peerAddr.size()))
throw std::runtime_error("Unable to begin connecting");
log_debug_printf(io, "Connecting to %s\n", peerName.c_str());
+2
View File
@@ -56,6 +56,8 @@ unsigned long version_int();
/** Free some internal global allocations to avoid false positives in
* valgrind (or similar) tools looking for memory leaks.
*
* Calls libevent_global_shutdown() when available (libevent >=2.1).
*
* @warning This function is optional.
* If you don't understand the intended use case, then do not call it!
*
+3
View File
@@ -45,6 +45,9 @@ unsigned long version_int()
void cleanup_for_valgrind()
{
#if LIBEVENT_VERSION_NUMBER >= 0x02010000
libevent_global_shutdown();
#endif
impl::logger_shutdown();
impl::UDPManager::cleanup();
}
-1
View File
@@ -115,7 +115,6 @@ MAIN(testev)
testPlan(14);
test_call();
test_fill_evbuf();
libevent_global_shutdown();
cleanup_for_valgrind();
return testDone();
}
-1
View File
@@ -212,7 +212,6 @@ MAIN(testsock)
test_from_wire();
test_to_wire();
testDiag("Done");
libevent_global_shutdown();
cleanup_for_valgrind();
return testDone();
}
-1
View File
@@ -158,7 +158,6 @@ int main(int argc, char *argv[])
testSearch(false, {"hello"});
testSearch(true , {"one", "two"});
testSearch(false, {"one", "two"});
libevent_global_shutdown();
cleanup_for_valgrind();
return testDone();
}