mem: multi-clients support for SharedMemoryServer

Record the client session with a map instead of a single unique_ptr so
our server can interact with multiple clients at once.

This will also avoid a race condition case where the client thought it
has closed previous connection and is trying to a new one while the
server hasn't clean up the previous entry and raise a fatal error.

Change-Id: Id08154fc4b54d2611629875b3f4e0d66c0e2ed92
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/61049
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Yu-hsin Wang <yuhsingw@google.com>
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
This commit is contained in:
Jui-Min Lee
2022-07-06 15:49:45 +08:00
committed by Jui-min Lee
parent f5d15871f3
commit b6dcae31ee
2 changed files with 6 additions and 6 deletions

View File

@@ -30,6 +30,7 @@
#include <memory>
#include <string>
#include <unordered_map>
#include "base/pollevent.hh"
#include "params/SharedMemoryServer.hh"
@@ -86,7 +87,8 @@ class SharedMemoryServer : public SimObject
int serverFd;
std::unique_ptr<ListenSocketEvent> listenSocketEvent;
std::unique_ptr<ClientSocketEvent> clientSocketEvent;
std::unordered_map<int, std::unique_ptr<ClientSocketEvent>>
clientSocketEvents;
};
} // namespace memory