Skip to content

rtpengine: initialize poll events after reconnecting a node - #4532

Open
Th0masL wants to merge 1 commit into
OpenSIPS:masterfrom
Th0masL:fix/rtpengine-reconnect-poll-events
Open

Th0masL wants to merge 1 commit into
OpenSIPS:masterfrom
Th0masL:fix/rtpengine-reconnect-poll-events

Conversation

@Th0masL

@Th0masL Th0masL commented Dec 3, 2026

Copy link
Copy Markdown

Summary

Initialize the poll event fields after reconnecting an RTPengine control socket, preventing spurious reply timeouts when the cached socket was unavailable on entry.

Details

In send_rtpe_command(), the input-draining block initializes fds[0] only when a cached socket exists.

If the cached socket is -1, that block is skipped. A successful reconnect then sets fds[0].fd, but leaves events uninitialized. Consequently, poll() may not report an available reply, and OpenSIPS can incorrectly time out and disable a responsive node.

This can occur when an RTPengine hostname cannot be resolved at startup but becomes resolvable later.

Related: #3532 updated the descriptor after reconnecting, but did not initialize the event fields on this path.

Solution

After a successful reconnect, also set:

  • fds[0].events = POLLIN
  • fds[0].revents = 0

Validated using a real OpenSIPS build and a mock RTPengine control endpoint, with the hostname initially unresolvable and made resolvable after startup:

Variant Spurious reply timeouts
Before 2
After 0

The patched version recovered promptly once the name became resolvable. The original version experienced additional timeouts despite replies arriving; its behavior depends on uninitialized stack contents.

Testing was performed on Linux ARM64 using a hosts-file change. AMD64, IPv6 and real DNS-cache behavior were not tested.

Compatibility

No configuration changes are required. Existing socket lifecycle, retry counts and node-disabling policy are unchanged.

This patch only initializes polling state. It does not introduce DNS refresh or cached-socket invalidation.

Closing issues

None.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant