Revision | d6f6c0e4c13e15a265702a2c97c61a0ea3ce24eb (tree) |
---|---|
Zeit | 2014-02-26 13:36:58 |
Autor | Hiroaki Nakano <nakano.hiroaki@nttc...> |
Commiter | Hiroaki Nakano |
Merge branch 'fix_memory_leak' into v3.1.1-devel
@@ -621,6 +621,8 @@ public: | ||
621 | 621 | void run(); |
622 | 622 | void stop(); |
623 | 623 | |
624 | + boost::shared_ptr<boost::thread> vs_thread_ptr; | |
625 | + | |
624 | 626 | void connection_active(const boost::asio::ip::tcp::endpoint &); |
625 | 627 | void connection_inactive(const boost::asio::ip::tcp::endpoint &); |
626 | 628 | void release_session(const tcp_session *session_ptr); |
@@ -249,7 +249,7 @@ void l7vsd::add_virtual_service(const virtualservice_element *in_vselement, e | ||
249 | 249 | try { |
250 | 250 | |
251 | 251 | // create thread and run |
252 | - vs_threads.create_thread(boost::bind(&virtual_service::run, vsptr)); | |
252 | + (*vsptr).vs_thread_ptr = boost::shared_ptr<boost::thread>(vs_threads.create_thread(boost::bind(&virtual_service::run, vsptr))); | |
253 | 253 | |
254 | 254 | } catch (...) { |
255 | 255 | std::stringstream buf; |
@@ -348,6 +348,8 @@ void l7vsd::del_virtual_service(const virtualservice_element *in_vselement, e | ||
348 | 348 | if (vslist.end() != vsitr) { |
349 | 349 | // vs stop |
350 | 350 | (*vsitr)->stop(); |
351 | + (*vsitr)->vs_thread_ptr->join(); | |
352 | + vs_threads.remove_thread((*vsitr)->vs_thread_ptr.get()); | |
351 | 353 | // vs finalize |
352 | 354 | (*vsitr)->finalize(err); |
353 | 355 |
@@ -791,14 +793,14 @@ void l7vsd::flush_virtual_service(error_code &err) | ||
791 | 793 | |
792 | 794 | // vs stop |
793 | 795 | (*itr)->stop(); |
796 | + // join virtualservice threads | |
797 | + (*itr)->vs_thread_ptr->join(); | |
798 | + vs_threads.remove_thread((*itr)->vs_thread_ptr.get()); | |
794 | 799 | // vs finalize |
795 | 800 | (*itr)->finalize(err); |
796 | 801 | } |
797 | 802 | } |
798 | 803 | |
799 | - // join virtualservice threads | |
800 | - vs_threads.join_all(); | |
801 | - | |
802 | 804 | // replication switch to slave |
803 | 805 | rep->switch_to_slave(); |
804 | 806 | } |