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:
Jon Siwek 2014-08-28 13:13:30 -05:00
parent 73cc81f44a
commit 675fba3fde
21 changed files with 364 additions and 58 deletions

29
src/Flare.cc Normal file
View 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;
}