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

ENT-14195 1. Refactored cf-reactor event handling with one unified interface#6353
victormlg wants to merge 1 commit into
cfengine:masterfrom
victormlg:event-handling-1-refactor

Conversation

@victormlg

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
{
    int *all_fds; // heap allocated array of fds
    size_t all_fds_capacity; // total number of fds. number of nova fds + number of event fds 
    size_t num_nova_fds; // this is returned by the reactor-plugin
    size_t num_fds; // this is 1
    // the first (num_nova_fds - 1) slots in the array are reserved for the reactor-plugin, the last one is reserved for the event driven code.

    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().

Signed-off-by: Victor Moene <victor.moene@northern.tech>
@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
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.

1 participant