merge: from 3.3.6 to main branch#33503
Conversation
Summary of ChangesHello @guanshengliang, 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 integrates a new authentication feature set, likely intended for enterprise deployments, by introducing necessary global variables, message types, and error codes. It establishes a periodic authentication heartbeat and updates the configuration system to manage these new parameters. Additionally, it refines message content handling during synchronous communication failures and ensures that new error codes are properly recognized in testing. 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 introduces new authentication-related features, including global configuration variables, message types, and error codes. The changes are generally well-structured, but there are a few areas related to naming clarity and memory management that require attention. Specifically, the naming of authentication intervals could be more distinct, and a potential memory leak was identified in the tmsgSendSyncReq function due to commented-out cleanup logic. Additionally, error handling for message queue operations should be robust.
| // if (code != 0) { | ||
| // rpcFreeCont(pMsg->pCont); | ||
| // pMsg->pCont = NULL; | ||
| // } |
There was a problem hiding this comment.
The lines responsible for freeing pMsg->pCont on error (if (code != 0) { rpcFreeCont(pMsg->pCont); pMsg->pCont = NULL; }) have been commented out. This changes the memory management contract: if tmsgSendSyncReq fails, the caller is now responsible for freeing pMsg->pCont. This could easily lead to memory leaks if callers are not updated to handle this new responsibility. Please either restore the memory freeing logic or clearly document this change in responsibility.
| // if (code != 0) { | |
| // rpcFreeCont(pMsg->pCont); | |
| // pMsg->pCont = NULL; | |
| // } | |
| if (code != 0) { | |
| rpcFreeCont(pMsg->pCont); | |
| pMsg->pCont = NULL; | |
| } |
| void *pReq = mndBuildTimerMsg(&contLen); | ||
| if (pReq != NULL) { | ||
| SRpcMsg rpcMsg = {.msgType = TDMT_MND_AUTH_HB_TIMER, .pCont = pReq, .contLen = contLen, .info.notFreeAhandle = 1, .info.ahandle = 0}; | ||
| // TODO check return value |
There was a problem hiding this comment.
The return value of tmsgPutToQueue is not checked. If this function fails, the memory allocated for pReq by mndBuildTimerMsg will not be freed, leading to a memory leak. It's crucial to always check return values for functions that can fail and handle errors appropriately, including freeing allocated resources.
if (tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg) < 0) {
mError("failed to put into write-queue since %s, line:%d", terrstr(), __LINE__);
rpcFreeCont(pReq);
}| #ifdef TD_ENTERPRISE | ||
| bool tsAuthServer = 0; | ||
| bool tsAuthReq = 0; | ||
| int32_t tsAuthReqInterval = 2592000; |
There was a problem hiding this comment.
The variable tsAuthReqInterval is set to a default of 30 days, while tsAuthReqHBInterval is 5 seconds. Both names contain "Interval", which can be confusing. If tsAuthReqInterval represents a full re-authentication period rather than a heartbeat interval, consider renaming it to something like tsAuthReauthPeriod or tsAuthCheckPeriod for better clarity and to avoid ambiguity with tsAuthReqHBInterval.
Description
Please briefly describe the code changes in this pull request.
Checklist
Please check the items in the checklist if applicable.