Merge with ns-3-dev
authorsocket
Tue, 16 Aug 2011 20:26:04 +0200
changeset 7434 843bfc666dcf
parent 7433 b29227c0eee0 (current diff)
parent 7431 17902e1844be (diff)
child 7435 88f57d23bb14
Merge with ns-3-dev
--- a/src/core/model/unix-fd-reader.cc	Tue Aug 16 20:22:40 2011 +0200
+++ b/src/core/model/unix-fd-reader.cc	Tue Aug 16 20:26:04 2011 +0200
@@ -110,15 +110,13 @@
 {
   m_stop = true;
 
-  // signal the read thread and close the write end of the event pipe
+  // signal the read thread
   if (m_evpipe[1] != -1)
     {
       char zero = 0;
       ssize_t len = write (m_evpipe[1], &zero, sizeof (zero));
       if (len != sizeof (zero))
         NS_LOG_WARN ("incomplete write(): " << strerror (errno));
-      close (m_evpipe[1]);
-      m_evpipe[1] = -1;
     }
 
   // join the read thread
@@ -128,6 +126,13 @@
       m_readThread = 0;
     }
 
+  // close the write end of the event pipe
+  if (m_evpipe[1] != -1)
+    {
+      close (m_evpipe[1]);
+      m_evpipe[1] = -1;
+    }
+
   // close the read end of the event pipe
   if (m_evpipe[0] != -1)
     {
@@ -167,26 +172,26 @@
       if (FD_ISSET (m_evpipe[0], &readfds))
         {
           // drain the event pipe
-          ssize_t len;
           for (;;)
             {
               char buf[1024];
-              len = read (m_evpipe[0], buf, sizeof (buf));
+              ssize_t len = read (m_evpipe[0], buf, sizeof (buf));
               if (len == 0)
                 {
                   NS_FATAL_ERROR ("event pipe closed");
                 }
               if (len < 0)
                 {
-                  break;
+                  if (errno == EAGAIN || errno == EINTR || errno == EWOULDBLOCK)
+                    {
+                      break;
+                    }
+                  else
+                    {
+                      NS_FATAL_ERROR ("read() failed: " << strerror (errno));
+                    }
                 }
             }
-
-          if (len < 0 && errno != EAGAIN && errno != EWOULDBLOCK)
-            {
-              NS_LOG_WARN ("read() failed: " << strerror (errno));
-              break;
-            }
         }
 
       if (m_stop)
--- a/wscript	Tue Aug 16 20:22:40 2011 +0200
+++ b/wscript	Tue Aug 16 20:26:04 2011 +0200
@@ -827,7 +827,8 @@
     if ((not Options.options.run)
         and (not Options.options.pyrun) 
         and ('clean' not in Options.arg_line)
-        and ('distclean' not in Options.arg_line)):
+        and ('distclean' not in Options.arg_line)
+        and ('shell' not in Options.arg_line)):
 
         # Print the list of built modules.
         print