fix: clearing user_ip in taos_options_connection does not take effect#33229
fix: clearing user_ip in taos_options_connection does not take effect#33229guanshengliang merged 8 commits into3.3.6from
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 addresses an issue related to the handling and verification of user-provided IP addresses through the 'TSDB_OPTION_CONNECTION_USER_IP' connection option. It introduces a dedicated field for storing this user IP, updates the internal logic for setting and retrieving it, and enhances the test suite to thoroughly validate its functionality. The changes ensure that user-specified IP addresses are correctly managed and reflected in the system's connection information. 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 appears to fix an issue related to setting a user-defined IP for a connection, including adding support for dual-stack IPs. The changes include updates to a C example, C++ tests, and the server-side management node implementation. My review has found a critical issue in the C example that could lead to a crash, along with several medium-severity issues related to code clarity, best practices, and maintainability in the example, test, and server code. Please review the detailed comments for suggestions on how to address these points.
| TAOS *taos = taos_connect(host, user, passwd, db, port); | ||
| taos_options_connection(taos, TSDB_OPTION_CONNECTION_USER_IP, "localhost"); | ||
|
|
||
| code = taos_options_connection(taos, TSDB_OPTION_CONNECTION_USER_IP, "192.168.1.1"); |
There was a problem hiding this comment.
| #include <stdio.h> | ||
| #include <stdlib.h> | ||
| #include <string.h> | ||
| #include <taos.h> |
| TAOS *taos = taos_connect(host, user, passwd, db, port); | ||
| taos_options_connection(taos, TSDB_OPTION_CONNECTION_USER_IP, "localhost"); | ||
|
|
||
| code = taos_options_connection(taos, TSDB_OPTION_CONNECTION_USER_IP, "192.168.1.1"); |
|
|
||
| taos_free_result(pRes); | ||
|
|
||
| ASSERT(1); |
| code = taos_options_connection(pConn, TSDB_OPTION_CONNECTION_USER_IP, "1292.168.0.2"); | ||
| //ASSERT(code != 0); // add dual alter | ||
| CHECK_TAOS_OPTION_IP_ERROR(pConn, userIp, INADDR_NONE); | ||
| taosSsleep(6); |
There was a problem hiding this comment.
The magic number 6 is used for sleeping, likely to wait for a server-side update to propagate. Using magic numbers makes the code harder to understand and maintain. It would be better to define this as a named constant related to the underlying mechanism (e.g., HEARTBEAT_INTERVAL_SECONDS * 2) and use that constant here and in other similar places in this test file.
Description
Please briefly describe the code changes in this pull request.
Checklist
Please check the items in the checklist if applicable.