mirror of
https://github.com/zeek/zeek.git
synced 2025-10-14 04:28:20 +00:00
Merge remote-tracking branch 'origin/topic/jsiwek/improve_comm_loop'
* origin/topic/jsiwek/improve_comm_loop: Add a simple FD_Set wrapper/helper class. Fix Pipe copy/assignment to make a copy of flags. Fix possible abort on writing to a full pipe. Remove timeouts from remote communication loop.
This commit is contained in:
commit
e9692958f0
22 changed files with 448 additions and 65 deletions
56
src/Pipe.h
Normal file
56
src/Pipe.h
Normal file
|
@ -0,0 +1,56 @@
|
|||
// See the file "COPYING" in the main distribution directory for copyright.
|
||||
|
||||
#ifndef BRO_PIPE_H
|
||||
#define BRO_PIPE_H
|
||||
|
||||
namespace bro {
|
||||
|
||||
class Pipe {
|
||||
public:
|
||||
|
||||
/**
|
||||
* Create a pair of file descriptors via pipe(), or aborts if it cannot.
|
||||
* @param flags0 file descriptor flags to set on read end of pipe.
|
||||
* @param flags1 file descriptor flags to set on write end of pipe.
|
||||
* @param status_flags0 descriptor status flags to set on read end of pipe.
|
||||
* @param status_flags1 descriptor status flags to set on write end of pipe.
|
||||
*/
|
||||
Pipe(int flags0 = 0, int flags1 = 0, int status_flags0 = 0,
|
||||
int status_flags1 = 0);
|
||||
|
||||
/**
|
||||
* Close the pair of file descriptors owned by the object.
|
||||
*/
|
||||
~Pipe();
|
||||
|
||||
/**
|
||||
* Make a copy of another Pipe object (file descriptors are dup'd).
|
||||
*/
|
||||
Pipe(const Pipe& other);
|
||||
|
||||
/**
|
||||
* Assign a Pipe object by closing file descriptors and duping those of
|
||||
* the other.
|
||||
*/
|
||||
Pipe& operator=(const Pipe& other);
|
||||
|
||||
/**
|
||||
* @return the file descriptor associated with the read-end of the pipe.
|
||||
*/
|
||||
int ReadFD() const
|
||||
{ return fds[0]; }
|
||||
|
||||
/**
|
||||
* @return the file descriptor associated with the write-end of the pipe.
|
||||
*/
|
||||
int WriteFD() const
|
||||
{ return fds[1]; }
|
||||
|
||||
private:
|
||||
int fds[2];
|
||||
int flags[2];
|
||||
};
|
||||
|
||||
} // namespace bro
|
||||
|
||||
#endif // BRO_PIPE_H
|
Loading…
Add table
Add a link
Reference in a new issue