Move some logic from main loader program to logging source file.

This commit is contained in:
Christian Deacon
2025-02-26 17:02:31 -05:00
parent 2a3fd9bbc0
commit 09e3665472
3 changed files with 18 additions and 4 deletions

View File

@@ -254,10 +254,7 @@ int main(int argc, char *argv[])
}
#ifdef ENABLE_FILTER_LOGGING
if (rb)
{
ring_buffer__poll(rb, RB_TIMEOUT);
}
PollFiltersRb(rb);
#endif
usleep(sleep_time);

View File

@@ -103,6 +103,21 @@ void LogMsg(config__t* cfg, int req_lvl, int error, const char* msg, ...)
va_end(args);
}
/**
* Polls the filters map ringbuffer.
*
* @param rb A pointer to the ringbuffer.
*
* @return void
*/
void PollFiltersRb(struct ring_buffer* rb)
{
if (rb)
{
ring_buffer__poll(rb, RB_TIMEOUT);
}
}
/**
* Callback for BPF ringbuffer event (filter logging).
*

View File

@@ -17,4 +17,6 @@
extern int doing_stats;
void LogMsg(config__t* cfg, int req_lvl, int error, const char* msg, ...);
void PollFiltersRb(struct ring_buffer* rb);
int HandleRbEvent(void* ctx, void* data, size_t sz);