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

View file

@ -6,8 +6,9 @@
#include "config.h"
#include "List.h"
#include "util.h"
#include "Flare.h"
#include <list>
#include <vector>
#ifdef NEED_KRB5_H
# include <krb5.h>
@ -95,6 +96,11 @@ public:
// Returns underlying fd if available, -1 otherwise.
virtual int Fd() { return -1; }
// Returns supplementary file descriptors that become read-ready in order
// to signal that there is some work that can be performed.
virtual std::vector<int> FdSupplements() const
{ return std::vector<int>(); }
// Makes sure that no additional protocol data is written into
// the output stream. If this is activated, the output cannot
// be read again by any of these classes!
@ -177,6 +183,7 @@ public:
virtual void Clear();
virtual bool Eof() { return eof; }
virtual int Fd() { return fd; }
virtual std::vector<int> FdSupplements() const;
virtual void Stats(char* buffer, int length);
private:
@ -240,6 +247,8 @@ private:
ChunkQueue* pending_tail;
pid_t pid;
bro::Flare write_flare;
bro::Flare read_flare;
};
// Chunked I/O using an SSL connection.
@ -262,6 +271,7 @@ public:
virtual void Clear();
virtual bool Eof() { return eof; }
virtual int Fd() { return socket; }
virtual std::vector<int> FdSupplements() const;
virtual void Stats(char* buffer, int length);
private:
@ -303,6 +313,8 @@ private:
// One SSL for all connections.
static SSL_CTX* ctx;
bro::Flare write_flare;
};
#include <zlib.h>
@ -328,6 +340,8 @@ public:
virtual bool Eof() { return io->Eof(); }
virtual int Fd() { return io->Fd(); }
virtual std::vector<int> FdSupplements() const
{ return io->FdSupplements(); }
virtual void Stats(char* buffer, int length);
void EnableCompression(int level)