mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 16:48:19 +00:00
Further threading and API restructuring for logging and input
frameworks. There were a number of cases that weren't thread-safe. In particular, we don't use std::string anymore for anything that's passed between threads (but instead plain old const char*, with manual memmory managmenet). This is still a check-point commit, I'll do more testing.
This commit is contained in:
parent
490859cfef
commit
87e10b5f97
31 changed files with 692 additions and 381 deletions
|
@ -4,10 +4,11 @@
|
|||
#define INPUT_READERFRONTEND_H
|
||||
|
||||
#include "ReaderBackend.h"
|
||||
|
||||
#include "threading/MsgThread.h"
|
||||
#include "threading/SerialTypes.h"
|
||||
|
||||
#include "Val.h"
|
||||
|
||||
namespace input {
|
||||
|
||||
class Manager;
|
||||
|
@ -25,6 +26,8 @@ public:
|
|||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* info: The meta information struct for the writer.
|
||||
*
|
||||
* type: The backend writer type, with the value corresponding to the
|
||||
* script-level \c Input::Reader enum (e.g., \a READER_ASCII). The
|
||||
* frontend will internally instantiate a ReaderBackend of the
|
||||
|
@ -32,7 +35,7 @@ public:
|
|||
*
|
||||
* Frontends must only be instantiated by the main thread.
|
||||
*/
|
||||
ReaderFrontend(bro_int_t type);
|
||||
ReaderFrontend(const ReaderBackend::ReaderInfo& info, EnumVal* type);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
|
@ -52,7 +55,7 @@ public:
|
|||
*
|
||||
* This method must only be called from the main thread.
|
||||
*/
|
||||
void Init(const ReaderBackend::ReaderInfo& info, const int arg_num_fields, const threading::Field* const* fields);
|
||||
void Init(const int arg_num_fields, const threading::Field* const* fields);
|
||||
|
||||
/**
|
||||
* Force an update of the current input source. Actual action depends
|
||||
|
@ -100,12 +103,12 @@ public:
|
|||
*
|
||||
* This method is safe to call from any thread.
|
||||
*/
|
||||
string Name() const;
|
||||
const char* Name() const;
|
||||
|
||||
/**
|
||||
* Returns the additional reader information passed into the constructor.
|
||||
*/
|
||||
const ReaderBackend::ReaderInfo& Info() const { return info; }
|
||||
const ReaderBackend::ReaderInfo& Info() const { assert(info); return *info; }
|
||||
|
||||
/**
|
||||
* Returns the number of log fields as passed into the constructor.
|
||||
|
@ -120,24 +123,14 @@ public:
|
|||
protected:
|
||||
friend class Manager;
|
||||
|
||||
/**
|
||||
* Returns the name of the backend's type.
|
||||
*/
|
||||
const string& TypeName() const { return ty_name; }
|
||||
|
||||
/**
|
||||
* Sets the name of the backend's type.
|
||||
*/
|
||||
void SetTypeName(const string& name) { ty_name = name; }
|
||||
|
||||
private:
|
||||
ReaderBackend* backend; // The backend we have instanatiated.
|
||||
ReaderBackend::ReaderInfo info; // Meta information as passed to Init().
|
||||
ReaderBackend::ReaderInfo* info; // Meta information.
|
||||
const threading::Field* const* fields; // The input fields.
|
||||
int num_fields; // Information as passed to Init().
|
||||
string ty_name; // Backend type, set by manager.
|
||||
bool disabled; // True if disabled.
|
||||
bool initialized; // True if initialized.
|
||||
const char* name; // Descriptive name.
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue