add comments about previous bug fix
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Wed, 07 May 2008 11:33:40 -0700
changeset 3006 054b9ca57390
parent 3005 cc521f35f033
child 3007 364e3943c8f0
add comments about previous bug fix
src/simulator/simulator.cc
--- a/src/simulator/simulator.cc	Tue May 06 12:20:10 2008 -0700
+++ b/src/simulator/simulator.cc	Wed May 07 11:33:40 2008 -0700
@@ -428,6 +428,12 @@
 {
   if (m_priv == 0) 
     {
+      /* Note: we call LogSetTimePrinter below _after_ calling CreateObject because
+       * CreateObject can trigger calls to the logging framework which would call
+       * the TimePrinter function above which would call Simulator::Now which would
+       * call Simulator::GetPriv, and, thus, get us in an infinite recursion until the
+       * stack explodes.
+       */
       m_priv = CreateObject<SimulatorPrivate> ();
       Ptr<Scheduler> scheduler = CreateObject<MapScheduler> ();
       m_priv->SetScheduler (scheduler);
@@ -444,6 +450,11 @@
     {
       return;
     }
+  /* Note: we have to call LogSetTimePrinter (0) below because if we do not do this,
+   * and restart a simulation after this call to Destroy, (which is legal), 
+   * Simulator::GetPriv will trigger again an infinite recursion until the stack 
+   * explodes.
+   */
   LogSetTimePrinter (0);
   m_priv->Destroy ();
   m_priv = 0;