libevent 2.0 compat
This commit is contained in:
+1
-1
@@ -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());
|
||||
|
||||
@@ -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!
|
||||
*
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -115,7 +115,6 @@ MAIN(testev)
|
||||
testPlan(14);
|
||||
test_call();
|
||||
test_fill_evbuf();
|
||||
libevent_global_shutdown();
|
||||
cleanup_for_valgrind();
|
||||
return testDone();
|
||||
}
|
||||
|
||||
@@ -212,7 +212,6 @@ MAIN(testsock)
|
||||
test_from_wire();
|
||||
test_to_wire();
|
||||
testDiag("Done");
|
||||
libevent_global_shutdown();
|
||||
cleanup_for_valgrind();
|
||||
return testDone();
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user