Skip to content

Commit 9f7c28e

Browse files
committed
raw: wait for a block in poll
get_block() polls the socket with a zero timeout, so on an idle interface the input worker spins and wakes up about 18,000 times per second, costing several percent of CPU on small routers. Waits up to 1 ms for a block instead. The worker still calls export_expired() about 1,000 times per second while idle, so expired flows of small caches are still found within a second. Upstream-Status: Pending
1 parent cc8e937 commit 9f7c28e

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

‎src/plugins/input/raw/src/raw.cpp‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,13 @@ void RawReader::open_ifc(const std::string& ifc)
258258
bool RawReader::get_block()
259259
{
260260
if ((m_pbd->hdr.bh1.block_status & TP_STATUS_USER) == 0) {
261-
// No data available at the moment
262-
if (poll(&m_pfd, 1, 0) == -1) {
261+
// No data available at the moment, wait for it shortly
262+
if (poll(&m_pfd, 1, 1) == -1 && errno != EINTR) {
263263
throw PluginError(std::string("poll: ") + strerror(errno));
264264
}
265-
return false;
265+
if ((m_pbd->hdr.bh1.block_status & TP_STATUS_USER) == 0) {
266+
return false;
267+
}
266268
}
267269
return true;
268270
}

0 commit comments

Comments
 (0)