!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; string channelHost;
uint16_t channelPort; uint16_t channelPort;
uv_loop_t *loopMain; uv_loop_t *loopMain;
bool isServerOrClient; bool isServerOrClient; // true is server, false is client
uv_rwlock_t mainAsync; uv_rwlock_t mainAsync;
uv_async_t asyncMainLoop; uv_async_t asyncMainLoop;
list<void *> lstMainThreadOP; list<void *> lstMainThreadOP;

View File

@ -86,7 +86,7 @@ struct TaskInformation {
bool hasInitial; bool hasInitial;
bool taskStop; bool taskStop;
bool taskFree; bool taskFree;
bool serverOrDaemon; bool serverOrDaemon; // true is server, false is daemon
bool masterSlave; bool masterSlave;
uv_loop_t *runLoop; uv_loop_t *runLoop;
void *taskClass; void *taskClass;
@ -198,7 +198,7 @@ struct HdcSessionStat {
}; };
struct HdcSession { 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 handshakeOK; // Is an expected peer side
bool isDead; bool isDead;
bool voteReset; bool voteReset;
@ -322,7 +322,7 @@ struct HdcChannel {
uint8_t uvHandleRef = 0; // libuv handle ref -- just main thread now uint8_t uvHandleRef = 0; // libuv handle ref -- just main thread now
bool handshakeOK; bool handshakeOK;
bool isDead; bool isDead;
bool serverOrClient; // client's channel/ server's channel bool serverOrClient; // true: server's channel, false: client's channel
bool childCleared; bool childCleared;
bool interactiveShellMode; // Is shell interactive mode bool interactiveShellMode; // Is shell interactive mode
bool keepAlive; // channel will not auto-close by server 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: { case OP_REMOVE: {
uv_rwlock_wrlock(&daemonAdmin); uv_rwlock_wrlock(&daemonAdmin);
if (mapDaemon.count(connectKey)) { if (mapDaemon.count(connectKey)) {
HDaemonInfo hDaemonInfo = mapDaemon[connectKey];
if (hDaemonInfo != nullptr) {
delete hDaemonInfo;
}
mapDaemon.erase(connectKey); mapDaemon.erase(connectKey);
} }
uv_rwlock_wrunlock(&daemonAdmin); uv_rwlock_wrunlock(&daemonAdmin);
@ -718,6 +722,10 @@ string HdcServer::AdminForwardMap(uint8_t opType, const string &taskString, HFor
case OP_REMOVE: { case OP_REMOVE: {
uv_rwlock_wrlock(&forwardAdmin); uv_rwlock_wrlock(&forwardAdmin);
if (mapForward.count(taskString)) { if (mapForward.count(taskString)) {
HForwardInfo hForwardInfo = mapForward[taskString];
if (hForwardInfo != nullptr) {
delete hForwardInfo;
}
mapForward.erase(taskString); mapForward.erase(taskString);
} }
uv_rwlock_wrunlock(&forwardAdmin); uv_rwlock_wrunlock(&forwardAdmin);