Repository: trafficserver Updated Branches: refs/heads/master dc0561c4d -> d8bc5089b
TS-3863: Add support for ASAN leak detection This closes #453 Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/d8bc5089 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/d8bc5089 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/d8bc5089 Branch: refs/heads/master Commit: d8bc5089b265574adf2d1ea3d904823eb9c4c30a Parents: dc0561c Author: Bryan Call <[email protected]> Authored: Wed Feb 3 16:48:35 2016 -0800 Committer: Bryan Call <[email protected]> Committed: Wed Feb 3 16:48:35 2016 -0800 ---------------------------------------------------------------------- iocore/aio/AIO.cc | 4 ++++ iocore/eventsystem/I_EThread.h | 2 ++ iocore/eventsystem/UnixEThread.cc | 5 +++++ iocore/net/UnixNetAccept.cc | 2 +- lib/ts/EventNotify.cc | 2 +- mgmt/ProcessManager.cc | 3 +++ proxy/Main.cc | 5 ++++- proxy/logging/Log.cc | 6 ++++++ 8 files changed, 26 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d8bc5089/iocore/aio/AIO.cc ---------------------------------------------------------------------- diff --git a/iocore/aio/AIO.cc b/iocore/aio/AIO.cc index 5fbeef7..cf6784f 100644 --- a/iocore/aio/AIO.cc +++ b/iocore/aio/AIO.cc @@ -458,6 +458,10 @@ aio_thread_main(void *arg) ink_mutex_acquire(&my_aio_req->aio_mutex); for (;;) { do { + if (unlikely(shutdown_event_system == true)) { + ink_mutex_release(&my_aio_req->aio_mutex); + return 0; + } current_req = my_aio_req; /* check if any pending requests on the atomic list */ if (!INK_ATOMICLIST_EMPTY(my_aio_req->aio_temp_list)) http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d8bc5089/iocore/eventsystem/I_EThread.h ---------------------------------------------------------------------- diff --git a/iocore/eventsystem/I_EThread.h b/iocore/eventsystem/I_EThread.h index c348217..4618360 100644 --- a/iocore/eventsystem/I_EThread.h +++ b/iocore/eventsystem/I_EThread.h @@ -56,6 +56,8 @@ enum ThreadType { DEDICATED, }; +extern bool shutdown_event_system; + /** Event System specific type of thread. http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d8bc5089/iocore/eventsystem/UnixEThread.cc ---------------------------------------------------------------------- diff --git a/iocore/eventsystem/UnixEThread.cc b/iocore/eventsystem/UnixEThread.cc index fb3af43..e178930 100644 --- a/iocore/eventsystem/UnixEThread.cc +++ b/iocore/eventsystem/UnixEThread.cc @@ -39,6 +39,8 @@ struct AIOCallback; #define THREAD_MAX_HEARTBEAT_MSECONDS 60 #define NO_ETHREAD_ID -1 +bool shutdown_event_system = false; + EThread::EThread() : generator((uint64_t)ink_get_hrtime_internal() ^ (uint64_t)(uintptr_t) this), ethreads_to_be_signalled(NULL), n_ethreads_to_be_signalled(0), main_accept_index(-1), id(NO_ETHREAD_ID), event_types(0), signal_hook(0), tt(REGULAR) @@ -168,6 +170,9 @@ EThread::execute() // give priority to immediate events for (;;) { + if (unlikely(shutdown_event_system == true)) { + return; + } // execute all the available external events that have // already been dequeued cur_time = ink_get_based_hrtime_internal(); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d8bc5089/iocore/net/UnixNetAccept.cc ---------------------------------------------------------------------- diff --git a/iocore/net/UnixNetAccept.cc b/iocore/net/UnixNetAccept.cc index 37ee6de..7096f7c 100644 --- a/iocore/net/UnixNetAccept.cc +++ b/iocore/net/UnixNetAccept.cc @@ -273,7 +273,7 @@ NetAccept::do_blocking_accept(EThread *t) // Use 'NULL' to Bypass thread allocator vc = (UnixNetVConnection *)this->getNetProcessor()->allocate_vc(NULL); - if (!vc) { + if (unlikely(!vc || shutdown_event_system == true)) { con.close(); return -1; } http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d8bc5089/lib/ts/EventNotify.cc ---------------------------------------------------------------------- diff --git a/lib/ts/EventNotify.cc b/lib/ts/EventNotify.cc index 28b509c..8cff3fc 100644 --- a/lib/ts/EventNotify.cc +++ b/lib/ts/EventNotify.cc @@ -92,7 +92,7 @@ EventNotify::wait(void) struct epoll_event ev; do { - nr_fd = epoll_wait(m_epoll_fd, &ev, 1, -1); + nr_fd = epoll_wait(m_epoll_fd, &ev, 1, 500000); } while (nr_fd == -1 && errno == EINTR); if (nr_fd == -1) http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d8bc5089/mgmt/ProcessManager.cc ---------------------------------------------------------------------- diff --git a/mgmt/ProcessManager.cc b/mgmt/ProcessManager.cc index 74f6041..0dc2300 100644 --- a/mgmt/ProcessManager.cc +++ b/mgmt/ProcessManager.cc @@ -56,6 +56,9 @@ startProcessManager(void *arg) } for (;;) { + if (unlikely(shutdown_event_system == true)) { + return NULL; + } if (pmgmt->require_lm) { pmgmt->pollLMConnection(); } http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d8bc5089/proxy/Main.cc ---------------------------------------------------------------------- diff --git a/proxy/Main.cc b/proxy/Main.cc index 45881e3..ee85e23 100644 --- a/proxy/Main.cc +++ b/proxy/Main.cc @@ -404,7 +404,10 @@ proxy_signal_handler(int signo, siginfo_t *info, void *) return; } - _exit(signo); + shutdown_event_system = true; + sleep(1); + + exit(signo); } // http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d8bc5089/proxy/logging/Log.cc ---------------------------------------------------------------------- diff --git a/proxy/logging/Log.cc b/proxy/logging/Log.cc index bbad5be..aa5468a 100644 --- a/proxy/logging/Log.cc +++ b/proxy/logging/Log.cc @@ -1153,6 +1153,9 @@ Log::preproc_thread_main(void *args) Log::preproc_notify[idx].lock(); while (true) { + if (unlikely(shutdown_event_system == true)) { + return NULL; + } size_t buffers_preproced = 0; LogConfig *current = (LogConfig *)configProcessor.get(log_configid); @@ -1195,6 +1198,9 @@ Log::flush_thread_main(void * /* args ATS_UNUSED */) Log::flush_notify->lock(); while (true) { + if (unlikely(shutdown_event_system == true)) { + return NULL; + } fdata = (LogFlushData *)ink_atomiclist_popall(flush_data_list); // invert the list
