mirror of
https://github.com/zeek/zeek.git
synced 2025-10-07 00:58:19 +00:00
Remove timeouts from remote communication loop.
The select() now blocks until there's work to do instead of relying on a small timeout value which can cause unproductive use of cpu cycles.
This commit is contained in:
parent
73cc81f44a
commit
675fba3fde
21 changed files with 364 additions and 58 deletions
29
src/Flare.cc
Normal file
29
src/Flare.cc
Normal file
|
@ -0,0 +1,29 @@
|
|||
// See the file "COPYING" in the main distribution directory for copyright.
|
||||
|
||||
#include "Flare.h"
|
||||
#include "util.h"
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
|
||||
using namespace bro;
|
||||
|
||||
Flare::Flare()
|
||||
: pipe(FD_CLOEXEC, FD_CLOEXEC, O_NONBLOCK, O_NONBLOCK)
|
||||
{
|
||||
}
|
||||
|
||||
void Flare::Fire()
|
||||
{
|
||||
char tmp;
|
||||
safe_write(pipe.WriteFD(), &tmp, 1);
|
||||
}
|
||||
|
||||
void Flare::Extinguish()
|
||||
{
|
||||
char tmp[256];
|
||||
|
||||
for ( ; ; )
|
||||
if ( read(pipe.ReadFD(), &tmp, sizeof(tmp)) == -1 && errno == EAGAIN )
|
||||
break;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue