[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[vidalia-svn] r3803: Don't start the UPNPControlThread in UPNPControl's construct (vidalia/trunk/src/vidalia/config)



Author: edmanm
Date: 2009-05-30 20:12:09 -0400 (Sat, 30 May 2009)
New Revision: 3803

Modified:
   vidalia/trunk/src/vidalia/config/UPNPControl.cpp
Log:

Don't start the UPNPControlThread in UPNPControl's constructor. Otherwise,
the thread's main loop could call UPNPControl::instance() before the constructor
has returned and set the value of _instance to non-zero, leading the UPNPControl's
constructor to get called again and another new thread created. Under the right
conditions, this can create a massive amount of threads, hit a limit, and then be
unable to create any more threads.


Modified: vidalia/trunk/src/vidalia/config/UPNPControl.cpp
===================================================================
--- vidalia/trunk/src/vidalia/config/UPNPControl.cpp	2009-05-30 05:13:51 UTC (rev 3802)
+++ vidalia/trunk/src/vidalia/config/UPNPControl.cpp	2009-05-31 00:12:09 UTC (rev 3803)
@@ -31,8 +31,10 @@
 /** Returns a pointer to this object's singleton instance. */
 UPNPControl* UPNPControl::instance()
 {
-  if (0 == _instance)
-    _instance = new UPNPControl;
+  if (0 == _instance) {
+    _instance = new UPNPControl();
+    _instance->_controlThread->start();
+  }
   return _instance;
 }
 
@@ -50,7 +52,6 @@
 
   _mutex = new QMutex();
   _controlThread = new UPNPControlThread(this);
-  _controlThread->start();
 }
 
 /** Destructor. cleanup() should be called before the object is destroyed.