13627105546 opened a new pull request, #17898:
URL: https://github.com/apache/nuttx/pull/17898

   If the nameserver already exists, return directly without calling 
dns_notify_nameserver to prevent cyclic notifications and high CPU usage.
   
   *Note: Please adhere to [Contributing 
Guidelines](https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md).*
   
   ## Summary
   
   When adding a nameserver via `dns_add_nameserver`, if the server already 
exists in the configuration (return value is `-EEXIST`), the function 
previously jumped to the `errout` label. This label executes 
`dns_notify_nameserver`, which sends a notification signal.
   
   In scenarios where multiple DNS updates occur or in master/slave 
synchronization contexts, this can lead to cyclic notifications and high CPU 
usage because the notification is sent even when no actual change was made 
(since the server already existed).
   
   This patch modifies the behavior to return directly when the nameserver 
exists, skipping the unnecessary `dns_notify_nameserver` call.
   
   ## Impact
   
   *   **Performance:** Reduces unnecessary CPU usage and potential message 
loops in DNS configuration updates.
   *   **Stability:** Prevents high CPU load caused by cyclic DNS notifications.
   *   **Users:** Users with dynamic DNS configurations or multiple DNS servers 
will experience more stable system behavior.
   
   ## Testing
   
   *   **Functional Test:**
       *   Simulated a scenario where `dns_add_nameserver` is called with an 
existing server address.
       *   Verified that `dns_notify_nameserver` is NOT called in this case.
       *   Verified that adding a *new* server still triggers the notification 
correctly.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to