Skip to content

Commit d2fd5f6

Browse files
Align with libbpf function names (#167)
* Align with libbpf function names * Expose poll, consumer leave next alone
1 parent 3f48c11 commit d2fd5f6

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

non-GPL/Events/Lib/EbpfEvents.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,22 @@ int ebpf_event_ctx__next(struct ebpf_event_ctx *ctx, int timeout)
663663
return consumed > 0 ? 0 : consumed;
664664
}
665665

666+
int ebpf_event_ctx__poll(struct ebpf_event_ctx *ctx, int timeout)
667+
{
668+
if (!ctx)
669+
return -1;
670+
671+
return ring_buffer__poll(ctx->ringbuf, timeout);
672+
}
673+
674+
int ebpf_event_ctx__consume(struct ebpf_event_ctx *ctx)
675+
{
676+
if (!ctx)
677+
return -1;
678+
679+
return ring_buffer__consume(ctx->ringbuf);
680+
}
681+
666682
void ebpf_event_ctx__destroy(struct ebpf_event_ctx **ctx)
667683
{
668684
if (!ctx)

non-GPL/Events/Lib/EbpfEvents.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,26 @@ uint64_t ebpf_event_ctx__get_features(struct ebpf_event_ctx *ctx);
4242

4343
/* Consumes as many events as possible from the event context and returns the
4444
* number consumed.
45+
*
46+
* returns 0 on success, or less than 0 on failure
4547
*/
4648
int ebpf_event_ctx__next(struct ebpf_event_ctx *ctx, int timeout);
4749

50+
/* Consumes as many events as possible from the event context and returns the
51+
* number consumed. This will internally poll for events.
52+
*
53+
* returns the number of events acted upon, or less than 0 on failure.
54+
*/
55+
int ebpf_event_ctx__poll(struct ebpf_event_ctx *ctx, int timeout);
56+
57+
/* Consumes as many events as possible from the event context and returns the
58+
* number consumed. Does not poll. This is good if you are polling outside
59+
* this library.
60+
*
61+
* returns the number of events acted upon, or less than 0 on failure.
62+
*/
63+
int ebpf_event_ctx__consume(struct ebpf_event_ctx *ctx);
64+
4865
void ebpf_event_ctx__destroy(struct ebpf_event_ctx **ctx);
4966

5067
/* Retrieve app trustlist map from ctx */

0 commit comments

Comments
 (0)