dev: Exit correctly in dist-gem5
authorMichael LeBeane <michael.lebeane@amd.com>
Wed, 14 Sep 2016 03:08:34 +0000 (23:08 -0400)
committerMichael LeBeane <michael.lebeane@amd.com>
Wed, 14 Sep 2016 03:08:34 +0000 (23:08 -0400)
The receiver thread in dist_iface is allowed to directly exit the simulation.
This can cause exit to be called twice if the main thread simultaneously wants
to exit the simulation.  Therefore, have the receiver thread enqueue a request
to exit on the primary event queue for the main simulation thread to handle.

src/dev/net/dist_iface.cc
src/dev/net/tcp_iface.cc

index 1025dffe34a30c4cd481374689e9995caffd6d40..0e48770ed2ea774cf3b0947d061c5ccd8b902971 100644 (file)
@@ -610,10 +610,10 @@ DistIface::recvThreadFunc(Event *recv_done, Tick link_delay)
             // because one of them called m5 exit. So we stop here.
             // Grab the eventq lock to stop the simulation thread
             curEventQueue()->lock();
-            exit_message("info",
-                         0,
-                         "Message server closed connection, "
-                         "simulation is exiting");
+            exitSimLoop("Message server closed connection, simulator "
+                        "is exiting");
+            curEventQueue()->unlock();
+            break;
         }
 
         // We got a valid dist header packet, let's process it
index 38fc7aef2c7f4088fdeb0f41a8064e9f4a776bc0..c9ca577786362609e62a4c8fe9fd580453b6c9dc 100644 (file)
@@ -267,9 +267,8 @@ TCPIface::sendTCP(int sock, const void *buf, unsigned length)
     ret = ::send(sock, buf, length, MSG_NOSIGNAL);
     if (ret < 0) {
         if (errno == ECONNRESET || errno == EPIPE) {
-            inform("send(): %s", strerror(errno));
-            exit_message("info", 0, "Message server closed connection, "
-                         "simulation is exiting");
+            exitSimLoop("Message server closed connection, simulation "
+                        "is exiting");
         } else {
             panic("send() failed: %s", strerror(errno));
         }