Skip to content

Commit

Permalink
Return number of CPUs with data for BPFPerfBufferTable::poll()
Browse files Browse the repository at this point in the history
  • Loading branch information
anakryiko committed Apr 2, 2018
1 parent 41134b1 commit b2e6870
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/cc/api/BPFTable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<perf_reader*>(ep_events_[i].data.ptr));
return cnt;
}

BPFPerfBuffer::~BPFPerfBuffer() {
Expand Down
2 changes: 1 addition & 1 deletion src/cc/api/BPFTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ class BPFPerfBuffer : public BPFTableBase<int, int> {
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,
Expand Down

0 comments on commit b2e6870

Please sign in to comment.