Skip to content

Commit

Permalink
Handle ring buffer processing error gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
hack3ric committed Mar 30, 2024
1 parent f5c3b71 commit 23b57d5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/run.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,19 +221,22 @@ static inline int send_ctrl_packet(struct send_options* s) {
return 0;
}

static int handle_send_event(struct send_options* s) {
try(send_ctrl_packet(s), _("error sending packet: %s"), strerror(-_ret));
return 0;
}

static int handle_rb_event(void* ctx, void* data, size_t data_sz) {
struct rb_item* item = data;
const char* name;
int ret;
switch (item->type) {
case RB_ITEM_LOG_EVENT:
return handle_log_event(&item->log_event);
name = N_("logging event");
ret = handle_log_event(&item->log_event);
break;
case RB_ITEM_SEND_OPTIONS:
return handle_send_event(&item->send_options);
name = N_("sending control packets");
ret = send_ctrl_packet(&item->send_options);
break;
}
if (ret < 0) log_error(_("error %s: %s"), gettext(name), strerror(-ret));
return 0;
}

#define MAX_EVENTS 10
Expand Down
2 changes: 2 additions & 0 deletions src/shared/try.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#ifdef _MIMIC_BPF
#else
#include <errno.h>

#include "../log.h"
#endif

Expand Down

0 comments on commit 23b57d5

Please sign in to comment.