Subject: [dtn-users] another ethcl patch

From: Lana Black <[email-masked]>
Date: Tue, 19 Feb 2013 12:42:55 +0000

Hi,

This patch fixes the excessive cpu usage by adding nanosleep() to
EthernetConvergenceLayer::Receiver::run() loop.

Also fixes the failing assertion because BeaconTimer is deleted instead
of being cancelled.
diff -r 2c5b711a66b0 servlib/conv_layers/EthConvergenceLayer.cc
--- a/servlib/conv_layers/EthConvergenceLayer.cc	Mon Feb 18 09:55:58 2013 +0000
+++ b/servlib/conv_layers/EthConvergenceLayer.cc	Tue Feb 19 12:37:02 2013 +0000
@@ -31,6 +31,7 @@
 #include <netpacket/packet.h>
 #include <sys/ioctl.h>
 #include <errno.h>
+#include <time.h>
 
 #include <oasys/io/NetUtils.h>
 #include <oasys/io/IO.h>
@@ -557,6 +558,9 @@
 
         if(should_stop())
             break;
+
+        struct timespec ts = { 0, 1*1000*1000 };  // 1 msec
+        nanosleep(&ts, NULL);
     }
 }
 
diff -r 2c5b711a66b0 servlib/conv_layers/EthConvergenceLayer.h
--- a/servlib/conv_layers/EthConvergenceLayer.h	Mon Feb 18 09:55:58 2013 +0000
+++ b/servlib/conv_layers/EthConvergenceLayer.h	Tue Feb 19 12:37:02 2013 +0000
@@ -155,8 +155,9 @@
         virtual void serialize(oasys::SerializeAction *a);
 
         ~Params() {
-            if(timer)
-                delete timer;
+            if(timer) {
+                timer->cancel();
+            }
         }
 
         u_int32_t beacon_interval_;       ///< Beacon Interval