Conversation
Summary of ChangesHello @yihaoDeng, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves a memory leak issue identified in the executor library. The change specifically targets an error handling path in the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request fixes a memory leak in qProcessRspMsg by ensuring pMsg->pCont is freed on an early exit path. The fix is correct and important for preventing resource leaks. I've also suggested a small refactoring to centralize resource cleanup and improve the function's structure for better maintainability.
| if (pMsg->info.ahandle == NULL) { | ||
| rpcFreeCont(pMsg->pCont); | ||
| qError("pMsg->info.ahandle is NULL"); | ||
| return; | ||
| } |
There was a problem hiding this comment.
While this change correctly fixes the memory leak, the function can be refactored to centralize resource cleanup and improve readability. This would avoid duplicated calls to rpcFreeCont.
Consider restructuring the function like this:
void qProcessRspMsg(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) {
if (pMsg->info.ahandle != NULL) {
SMsgSendInfo* pSendInfo = (SMsgSendInfo*)pMsg->info.ahandle;
qDebug("rsp msg got, code:%x, len:%d, 0x%" PRIx64 ":0x%" PRIx64,
pMsg->code, pMsg->contLen, TRACE_GET_ROOTID(&pMsg->info.traceId), TRACE_GET_MSGID(&pMsg->info.traceId));
SDataBuf buf = {.len = pMsg->contLen, .pData = NULL};
if (pMsg->contLen > 0) {
buf.pData = taosMemoryCalloc(1, pMsg->contLen);
if (buf.pData == NULL) {
pMsg->code = terrno;
} else {
memcpy(buf.pData, pMsg->pCont, pMsg->contLen);
}
}
(void)pSendInfo->fp(pSendInfo->param, &buf, pMsg->code);
destroySendMsgInfo(pSendInfo);
} else {
qError("pMsg->info.ahandle is NULL");
}
rpcFreeCont(pMsg->pCont);
}This approach ensures rpcFreeCont is always called once at the end of the function, making the cleanup logic more robust and easier to maintain against future changes.
Description
Please briefly describe the code changes in this pull request.
Jira: https://jira.taosdata.com:18080/browse/TD-
Checklist
Please check the items in the checklist if applicable.