summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael LeBeane <michael.lebeane@amd.com>2016-09-13 23:08:34 -0400
committerMichael LeBeane <michael.lebeane@amd.com>2016-09-13 23:08:34 -0400
commitfebab25957066cf9b470864b6bda38687918b36d (patch)
tree5b848413e9092c8c1c7a422b70e9228038e975db
parentcc58148fe11fd9f579cf7b918472552897c809fb (diff)
downloadgem5-febab25957066cf9b470864b6bda38687918b36d.tar.xz
dev: Exit correctly in dist-gem5
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.
-rw-r--r--src/dev/net/dist_iface.cc8
-rw-r--r--src/dev/net/tcp_iface.cc5
2 files changed, 6 insertions, 7 deletions
diff --git a/src/dev/net/dist_iface.cc b/src/dev/net/dist_iface.cc
index 1025dffe3..0e48770ed 100644
--- a/src/dev/net/dist_iface.cc
+++ b/src/dev/net/dist_iface.cc
@@ -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
diff --git a/src/dev/net/tcp_iface.cc b/src/dev/net/tcp_iface.cc
index 38fc7aef2..c9ca57778 100644
--- a/src/dev/net/tcp_iface.cc
+++ b/src/dev/net/tcp_iface.cc
@@ -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));
}