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.
This commit is contained in:
parent
cc58148fe1
commit
febab25957
2 changed files with 6 additions and 7 deletions
|
@ -610,10 +610,10 @@ DistIface::recvThreadFunc(Event *recv_done, Tick link_delay)
|
||||||
// because one of them called m5 exit. So we stop here.
|
// because one of them called m5 exit. So we stop here.
|
||||||
// Grab the eventq lock to stop the simulation thread
|
// Grab the eventq lock to stop the simulation thread
|
||||||
curEventQueue()->lock();
|
curEventQueue()->lock();
|
||||||
exit_message("info",
|
exitSimLoop("Message server closed connection, simulator "
|
||||||
0,
|
"is exiting");
|
||||||
"Message server closed connection, "
|
curEventQueue()->unlock();
|
||||||
"simulation is exiting");
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We got a valid dist header packet, let's process it
|
// We got a valid dist header packet, let's process it
|
||||||
|
|
|
@ -267,9 +267,8 @@ TCPIface::sendTCP(int sock, const void *buf, unsigned length)
|
||||||
ret = ::send(sock, buf, length, MSG_NOSIGNAL);
|
ret = ::send(sock, buf, length, MSG_NOSIGNAL);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
if (errno == ECONNRESET || errno == EPIPE) {
|
if (errno == ECONNRESET || errno == EPIPE) {
|
||||||
inform("send(): %s", strerror(errno));
|
exitSimLoop("Message server closed connection, simulation "
|
||||||
exit_message("info", 0, "Message server closed connection, "
|
"is exiting");
|
||||||
"simulation is exiting");
|
|
||||||
} else {
|
} else {
|
||||||
panic("send() failed: %s", strerror(errno));
|
panic("send() failed: %s", strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue