Skip to content

Conversation

@13627105546
Copy link
Contributor

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.

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.

If the nameserver already exists, return directly without calling dns_notify_nameserver to prevent cyclic notifications and high CPU usage.

Signed-off-by: daichuan <[email protected]>
@github-actions github-actions bot added Area: OS Components OS Components issues Size: XS The size of the change in this PR is very small labels Jan 14, 2026
@acassis acassis merged commit c738677 into apache:master Jan 15, 2026
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: OS Components OS Components issues Size: XS The size of the change in this PR is very small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants