mail[Wesnoth-commits] r43949 - in /trunk/src/ana: api/stats.hpp apps/chat/CMakeLists.txt src/asio_client.cpp src/asio_server.cpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by billybiset on July 06, 2010 - 05:41:
Author: billynux
Date: Tue Jul  6 05:41:40 2010
New Revision: 43949

URL: http://svn.gna.org/viewcvs/wesnoth?rev=43949&view=rev
Log:
Fixes a memory leak in ana.

Modified:
    trunk/src/ana/api/stats.hpp
    trunk/src/ana/apps/chat/CMakeLists.txt
    trunk/src/ana/src/asio_client.cpp
    trunk/src/ana/src/asio_server.cpp

Modified: trunk/src/ana/api/stats.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/ana/api/stats.hpp?rev=43949&r1=43948&r2=43949&view=diff
==============================================================================
--- trunk/src/ana/api/stats.hpp (original)
+++ trunk/src/ana/api/stats.hpp Tue Jul  6 05:41:40 2010
@@ -154,13 +154,14 @@
         public:
             stats_collector() :
                 io_service_(),
+                collector_thread_( NULL ),
                 accumulator_( 0, io_service_),
                 seconds_stats_( time::seconds(1), io_service_ ),
                 minutes_stats_( time::minutes(1), io_service_ ),
                 hours_stats_( time::hours(1), io_service_ ),
                 days_stats_( time::days(1), io_service_ )
             {
-                boost::thread t( boost::bind(&boost::asio::io_service::run, 
&io_service_) );
+                collector_thread_ = new boost::thread( 
boost::bind(&boost::asio::io_service::run, &io_service_) );
             }
 
             const stats* get_stats( stat_type type ) const
@@ -194,8 +195,17 @@
                 days_stats_.log_receive   ( buffer );
             }
 
+            ~stats_collector()
+            {
+                io_service_.stop();
+                collector_thread_->join();
+                delete collector_thread_;
+            }
+
         private:
             boost::asio::io_service io_service_;
+
+            boost::thread*       collector_thread_;
 
             detail::stats_logger accumulator_;
             detail::stats_logger seconds_stats_;

Modified: trunk/src/ana/apps/chat/CMakeLists.txt
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/ana/apps/chat/CMakeLists.txt?rev=43949&r1=43948&r2=43949&view=diff
==============================================================================
--- trunk/src/ana/apps/chat/CMakeLists.txt (original)
+++ trunk/src/ana/apps/chat/CMakeLists.txt Tue Jul  6 05:41:40 2010
@@ -9,3 +9,4 @@
 add_executable( client client.cpp )
 
 target_link_libraries( client ana )
+

Modified: trunk/src/ana/src/asio_client.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/ana/src/asio_client.cpp?rev=43949&r1=43948&r2=43949&view=diff
==============================================================================
--- trunk/src/ana/src/asio_client.cpp (original)
+++ trunk/src/ana/src/asio_client.cpp Tue Jul  6 05:41:40 2010
@@ -56,6 +56,7 @@
 asio_client::~asio_client()
 {
     stop_logging();
+    disconnect_listener();
 }
 
 ana::client* ana::client::create(ana::address address, ana::port pt)
@@ -172,6 +173,7 @@
 void asio_client::stop_logging()
 {
     delete stats_collector_;
+    stats_collector_ = NULL;
 }
 
 const ana::stats* asio_client::get_stats( ana::stat_type type ) const

Modified: trunk/src/ana/src/asio_server.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/ana/src/asio_server.cpp?rev=43949&r1=43948&r2=43949&view=diff
==============================================================================
--- trunk/src/ana/src/asio_server.cpp (original)
+++ trunk/src/ana/src/asio_server.cpp Tue Jul  6 05:41:40 2010
@@ -242,6 +242,7 @@
 void asio_server::stop_logging()
 {
     delete stats_collector_;
+    stats_collector_ = NULL;
 }
 
 const ana::stats* asio_server::get_stats( ana::stat_type type ) const




Related Messages


Powered by MHonArc, Updated Tue Jul 06 06:00:07 2010