mirror of
https://github.com/rsyslog/rsyslog.git
synced 2025-12-16 12:10:46 +01:00
Improve maintainability and robustness of the TCP server by clarifying locking/ownership, tightening invariants, and simplifying queueing. Also fix a long-standing pragma macro typo across the tree. Impact: Internal behavior only. EPOLL re-arm now occurs while holding pSess->mut; starvation cap counts only successful reads. Before/After: Before: EPOLL re-arm happened after leaving the critical section; read starvation cap counted loop iterations; closeSess() sometimes unlocked; select_* helpers used on non-epoll path; enqueueWork() returned status. After: EPOLLONESHOT is re-armed before unlocking; starvation cap counts only RS_RET_OK reads; closeSess() never unlocks; poll_* helpers replace select_*; enqueueWork() is void (best-effort). Technical details: - Replace notifyReArm() with rearmIoEvent() (EPOLL_CTL_MOD with EPOLLONESHOT|EPOLLET; asserts efd/sock; logs on failure). - doReceive(): explicit state machine; would-block path re-arms before unlock; close path unlocks then calls closeSess(); starvation handoff enqueues without re-arming. - Initialize ioDirection for listener and session descriptors; add assert(sock >= 0) and widespread ATTR_NONNULL annotations. - startWrkrPool(): single finalize rollback (cancel/join partial threads; destroy cond/mutex); stopWrkrPool(): destroy cond/mutex. - enqueueWork(): FIFO append under lock and cond signal; returns void. - Cleanup hardening on construct failure: free ppLstn, ppLstnPort, ppioDescrPtr; free fromHostIP on SessAccept() error. - Non-epoll: rename select_Add/Poll/IsReady -> poll_*; RunPoll() uses poll_* and sets sane ioDirection defaults. - Typo fix: standardize PRAGMA_IGNORE_Wswitch_enum in header and all users (action.c, rainerscript.c, template.c, tcpsrv.c).