!1668 对AdminDaemonMap和AdminForwardMap的OP_REMOVE操作增加相关数据的内存释放

Merge pull request !1668 from wenlong_12/20241120
This commit is contained in:
openharmony_ci 2024-11-22 09:17:24 +00:00 committed by Gitee
commit 60448c2371
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 12 additions and 4 deletions

View File

@ -59,7 +59,7 @@ protected:
string channelHost;
uint16_t channelPort;
uv_loop_t *loopMain;
bool isServerOrClient;
bool isServerOrClient; // true is server, false is client
uv_rwlock_t mainAsync;
uv_async_t asyncMainLoop;
list<void *> lstMainThreadOP;

View File

@ -86,7 +86,7 @@ struct TaskInformation {
bool hasInitial;
bool taskStop;
bool taskFree;
bool serverOrDaemon;
bool serverOrDaemon; // true is server, false is daemon
bool masterSlave;
uv_loop_t *runLoop;
void *taskClass;
@ -198,7 +198,7 @@ struct HdcSessionStat {
};
struct HdcSession {
bool serverOrDaemon; // instance of daemon or server
bool serverOrDaemon; // instance of daemon or server, true is server, false is daemon
bool handshakeOK; // Is an expected peer side
bool isDead;
bool voteReset;
@ -322,7 +322,7 @@ struct HdcChannel {
uint8_t uvHandleRef = 0; // libuv handle ref -- just main thread now
bool handshakeOK;
bool isDead;
bool serverOrClient; // client's channel/ server's channel
bool serverOrClient; // true: server's channel, false: client's channel
bool childCleared;
bool interactiveShellMode; // Is shell interactive mode
bool keepAlive; // channel will not auto-close by server

View File

@ -352,6 +352,10 @@ string HdcServer::AdminDaemonMap(uint8_t opType, const string &connectKey, HDaem
case OP_REMOVE: {
uv_rwlock_wrlock(&daemonAdmin);
if (mapDaemon.count(connectKey)) {
HDaemonInfo hDaemonInfo = mapDaemon[connectKey];
if (hDaemonInfo != nullptr) {
delete hDaemonInfo;
}
mapDaemon.erase(connectKey);
}
uv_rwlock_wrunlock(&daemonAdmin);
@ -718,6 +722,10 @@ string HdcServer::AdminForwardMap(uint8_t opType, const string &taskString, HFor
case OP_REMOVE: {
uv_rwlock_wrlock(&forwardAdmin);
if (mapForward.count(taskString)) {
HForwardInfo hForwardInfo = mapForward[taskString];
if (hForwardInfo != nullptr) {
delete hForwardInfo;
}
mapForward.erase(taskString);
}
uv_rwlock_wrunlock(&forwardAdmin);