Skip to content

ENT-14195 1. Refactored cf-reactor event handling with one unified interface - #6353

Open
victormlg wants to merge 1 commit into
cfengine:masterfrom
victormlg:event-handling-1-refactor
Open

victormlg wants to merge 1 commit into
cfengine:masterfrom
victormlg:event-handling-1-refactor

Conversation

@victormlg

@victormlg victormlg commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Rather than exposing the raw file-descriptor bookkeeping required for select(2), we introduce a unified interface that serves both the reactor-plugin and event-driven code paths. This is achieved by encapsulating all relevant state in a context struct, ReactorContext:

typedef struct ReactorContext
{
    Seq *fds // array of ReactorFd, which holds the fd and some metadata
    fd_set readfds;
} ReactorContext;
  • ReactorContextInitialize(): initializes the reactor-plugin and event-driven code. Wraps ReactorNovaInitialize()
  • ReactorContextSetupFileDescriptors(): populates readfds with the file descriptors to monitor, prior to the select() call.
  • ReactorContextHandleEvents(): iterates over the file descriptors and dispatches the appropriate action based on which ones were signaled as ready. Wraps ReactorNovaHandleTimeout and ReactorNovaHandleEvents().
  • ReactorContextFinalize(): releases the daemon's associated resources. Wraps ReactorNovaFinalize().

@victormlg
victormlg requested a review from larsewi September 7, 2026 11:53
@victormlg victormlg changed the title Refactored cf-reactor event handling with one unified interface ENT-14195 1. Refactored cf-reactor event handling with one unified interface Sep 7, 2026

@larsewi larsewi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we stored FDs in a dynamic list instead (e.g., Seq)? Furthermore, maybe the FD itself could be wrapped in a struct with flags to tell what type of FD it is, and whether or not it is owned by any external plugin.

Comment thread cf-reactor/cf-reactor.h Outdated
Comment thread cf-reactor/cf-reactor.h Outdated
@victormlg
victormlg force-pushed the event-handling-1-refactor branch from 83c7b85 to a126ca0 Compare September 15, 2026 11:43
Signed-off-by: Victor Moene <victor.moene@northern.tech>
@victormlg
victormlg force-pushed the event-handling-1-refactor branch from a126ca0 to 92c3957 Compare September 15, 2026 11:57
@victormlg
victormlg requested a review from larsewi September 15, 2026 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants