From b2e687001bb201b7c78b05df202a0ef3f0555ba4 Mon Sep 17 00:00:00 2001 From: Andrii Nakryiko Date: Mon, 2 Apr 2018 13:41:11 -0700 Subject: [PATCH] Return number of CPUs with data for BPFPerfBufferTable::poll() --- src/cc/api/BPFTable.cc | 7 +++---- src/cc/api/BPFTable.h | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/cc/api/BPFTable.cc b/src/cc/api/BPFTable.cc index 7fcce4681fbb..141d2f74b2dc 100644 --- a/src/cc/api/BPFTable.cc +++ b/src/cc/api/BPFTable.cc @@ -306,14 +306,13 @@ StatusTuple BPFPerfBuffer::close_all_cpu() { return StatusTuple(0); } -void BPFPerfBuffer::poll(int timeout_ms) { +int BPFPerfBuffer::poll(int timeout_ms) { if (epfd_ < 0) - return; + return -1; int cnt = epoll_wait(epfd_, ep_events_.get(), cpu_readers_.size(), timeout_ms); - if (cnt <= 0) - return; for (int i = 0; i < cnt; i++) perf_reader_event_read(static_cast(ep_events_[i].data.ptr)); + return cnt; } BPFPerfBuffer::~BPFPerfBuffer() { diff --git a/src/cc/api/BPFTable.h b/src/cc/api/BPFTable.h index 3a161a028a81..f87802ca9bd0 100644 --- a/src/cc/api/BPFTable.h +++ b/src/cc/api/BPFTable.h @@ -310,7 +310,7 @@ class BPFPerfBuffer : public BPFTableBase { StatusTuple open_all_cpu(perf_reader_raw_cb cb, perf_reader_lost_cb lost_cb, void* cb_cookie, int page_cnt); StatusTuple close_all_cpu(); - void poll(int timeout_ms); + int poll(int timeout_ms); private: StatusTuple open_on_cpu(perf_reader_raw_cb cb, perf_reader_lost_cb lost_cb,