poll-rework.patch
author Hajime Tazaki <tazaki@nict.go.jp>
Thu, 20 Jun 2013 09:56:26 +0900
changeset 26 0fca5307fd86
permissions -rw-r--r--
update a lot

diff -r 957c0c1b6549 -r 403f06f014ab model/dce-poll.cc
--- a/model/dce-poll.cc	Mon Oct 15 13:51:29 2012 +0900
+++ b/model/dce-poll.cc	Fri Oct 19 19:07:45 2012 +0900
@@ -19,7 +19,7 @@
 {
   int count = -1;
   int timed_out = 0;
-  Time endtime;
+  Time start_time, endtime;
   // key fd
   std::map <int, FileUsage*> toUnRef;
   Thread *current = Current ();
@@ -30,6 +30,8 @@
   NS_ASSERT (current != 0);
   int validFdCount = 0;
 
+  start_time = Now ();
+
   if (0 == timeout)
     {
       currentTable = 0;
@@ -37,7 +39,7 @@
     }
   else if (timeout > 0)
     {
-      endtime = Now () + MilliSeconds (timeout);
+      endtime = start_time + MilliSeconds (timeout);
     }
 
   for (uint32_t i = 0; i < nfds; ++i)
@@ -77,6 +79,10 @@
                   count++;
                   currentTable = 0;
                 }
+              if (mask < 0)
+                {
+                  NS_ASSERT (0);
+                }
             }
         }
       currentTable = 0; // Register only first time.
@@ -118,7 +124,7 @@
     }
 
   // Try to break infinite loop in poll with a 0 timeout !
-  if ( ( 0 == count ) && ( 0 == timeout ) )
+  if (start_time == Now ())
     {
       UtilsAdvanceTime (current);
     }
diff -r 957c0c1b6549 -r 403f06f014ab model/utils.cc
--- a/model/utils.cc	Mon Oct 15 13:51:29 2012 +0900
+++ b/model/utils.cc	Fri Oct 19 19:07:45 2012 +0900
@@ -272,10 +272,10 @@
 
   if (now == current->lastTime)
     {
-//      NS_LOG_DEBUG ("UtilsAdvanceTime current thread wait 1ms.");
-      //current->process->manager->Wait (Time ( MilliSeconds (1) ) );
-      NS_LOG_DEBUG ("UtilsAdvanceTime current thread wait 1µs.");
-      current->process->manager->Wait (Time ( MicroSeconds (1) ) );
+      NS_LOG_DEBUG ("UtilsAdvanceTime current thread wait 1ms.");
+      current->process->manager->Wait (Time ( MilliSeconds (4) ) ); // 250HZ?
+//      NS_LOG_DEBUG ("UtilsAdvanceTime current thread wait 1µs.");
+      //      current->process->manager->Wait (Time ( MicroSeconds (1) ) );
     }
 
   current->lastTime = Now ();