[OpenSIPS-Devel] [OpenSIPS/opensips] 9f2990: sockets_mgm: fix race in receive_fd causing infini...

Norm Brandinger noreply at github.com
Fri Jul 31 08:31:41 UTC 2026


  Branch: refs/heads/master
  Home:   https://github.com/OpenSIPS/opensips
  Commit: 9f2990ca1c64ac8dbd5bde2365e4cab12d9c0cad
      https://github.com/OpenSIPS/opensips/commit/9f2990ca1c64ac8dbd5bde2365e4cab12d9c0cad
  Author: Norm Brandinger <n.brandinger at gmail.com>
  Date:   2026-07-31 (Fri, 31 Jul 2026)

  Changed paths:
    M modules/sockets_mgm/sockets_mgm.c

  Log Message:
  -----------
  sockets_mgm: fix race in receive_fd causing infinite loop on reload (#3820)

During sockets_reload, all processes receive an IPC RPC to run
rpc_socket_reload_proc(). Non-dynamic (worker) processes close their
copy of each dynamic socket and then call receive_fd() on the shared
sock_mgm_unix[0] socketpair to get a fresh fd from the mgm process.

Because sock_mgm_unix[0] is shared across all workers and SOCK_STREAM
delivers bytes in order (not per-message), concurrent receive_fd()
calls race: worker A can consume the fd response intended for worker B.
When this happens, worker B receives worker A's fd response, which
references a socket already in worker B's listener list.  The
sock_listadd() macro then corrupts the linked list into a circular
loop (si->next == si), causing push_sock2list() to spin at 100% CPU
indefinitely.

Add a sock_mgm_reload_lock that serializes the entire
send-IPC-to-mgm + receive-fd sequence for worker processes.  Dynamic
(mgm) processes are excluded from this lock because they create
sockets directly via sock_mgm_add_listener() and never call
receive_fd(); including them would deadlock since the worker holding
the lock blocks on receive_fd() waiting for the mgm to process
rpc_sockets_send().

Fixes: OpenSIPS/opensips#3789



To unsubscribe from these emails, change your notification settings at https://github.com/OpenSIPS/opensips/settings/notifications



More information about the Devel mailing list