mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 00:28:21 +00:00
start adding a different text for empty records for the sqlite writer.
Sadly there also seems to be another deadlock issue which I am currently not really able to figure out - on shutdown sometimes (too often) the main thread + all sqlite threads wait for semaphores or mutexes.
This commit is contained in:
parent
8f71186bf7
commit
0fcc3db9a0
10 changed files with 33 additions and 7 deletions
|
@ -2,4 +2,4 @@
|
|||
@load ./readers/ascii
|
||||
@load ./readers/raw
|
||||
@load ./readers/benchmark
|
||||
|
||||
@load ./readers/sqlite
|
||||
|
|
|
@ -9,5 +9,9 @@ export {
|
|||
|
||||
## String to use for an unset &optional field.
|
||||
const unset_field = Log::unset_field &redef;
|
||||
|
||||
## String to use for empty fields. This should be different from
|
||||
## *unset_field* to make the output non-ambigious.
|
||||
const empty_field = Log::empty_field &redef;
|
||||
}
|
||||
|
||||
|
|
|
@ -57,3 +57,8 @@ const autospread: double;
|
|||
const addfactor: count;
|
||||
const stopspreadat: count;
|
||||
const timedspread: double;
|
||||
|
||||
module InputSQLite;
|
||||
const set_separator: string;
|
||||
const unset_field: string;
|
||||
const empty_field: string;
|
||||
|
|
|
@ -22,7 +22,17 @@ using threading::Field;
|
|||
|
||||
SQLite::SQLite(ReaderFrontend *frontend) : ReaderBackend(frontend)
|
||||
{
|
||||
io = new AsciiInputOutput(this, AsciiInputOutput::SeparatorInfo());
|
||||
set_separator.assign(
|
||||
(const char*) BifConst::LogSQLite::set_separator->Bytes(),
|
||||
BifConst::InputSQLite::set_separator->Len()
|
||||
);
|
||||
|
||||
unset_field.assign(
|
||||
(const char*) BifConst::LogSQLite::unset_field->Bytes(),
|
||||
BifConst::InputSQLite::unset_field->Len()
|
||||
);
|
||||
|
||||
io = new AsciiInputOutput(this, AsciiInputOutput::SeparatorInfo(set_separator, unset_field));
|
||||
}
|
||||
|
||||
SQLite::~SQLite()
|
||||
|
|
|
@ -47,6 +47,9 @@ private:
|
|||
sqlite3 *db;
|
||||
sqlite3_stmt *st;
|
||||
AsciiInputOutput* io;
|
||||
|
||||
string set_separator;
|
||||
string unset_field;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -87,6 +87,7 @@ const num_threads: count;
|
|||
module LogSQLite;
|
||||
|
||||
const set_separator: string;
|
||||
const empty_field: string;
|
||||
const unset_field: string;
|
||||
|
||||
# Options for the ElasticSearch writer.
|
||||
|
|
|
@ -30,9 +30,14 @@ SQLite::SQLite(WriterFrontend* frontend) : WriterBackend(frontend)
|
|||
BifConst::LogAscii::unset_field->Len()
|
||||
);
|
||||
|
||||
empty_field.assign(
|
||||
(const char*) BifConst::LogAscii::empty_field->Bytes(),
|
||||
BifConst::LogAscii::empty_field->Len()
|
||||
);
|
||||
|
||||
db = 0;
|
||||
|
||||
io = new AsciiInputOutput(this, AsciiInputOutput::SeparatorInfo(set_separator, unset_field));
|
||||
io = new AsciiInputOutput(this, AsciiInputOutput::SeparatorInfo(set_separator, unset_field, empty_field));
|
||||
}
|
||||
|
||||
SQLite::~SQLite()
|
||||
|
@ -134,7 +139,7 @@ bool SQLite::DoInit(const WriterInfo& info, int num_fields,
|
|||
&db,
|
||||
SQLITE_OPEN_READWRITE |
|
||||
SQLITE_OPEN_CREATE |
|
||||
SQLITE_OPEN_FULLMUTEX // perhaps change to nomutex
|
||||
SQLITE_OPEN_NOMUTEX // perhaps change to nomutex
|
||||
,
|
||||
NULL)) )
|
||||
return false;
|
||||
|
|
|
@ -46,9 +46,9 @@ private:
|
|||
sqlite3 *db;
|
||||
sqlite3_stmt *st;
|
||||
|
||||
string separator;
|
||||
string set_separator;
|
||||
string unset_field;
|
||||
string empty_field;
|
||||
|
||||
AsciiInputOutput* io;
|
||||
};
|
||||
|
|
|
@ -86,7 +86,6 @@ event bro_init()
|
|||
};
|
||||
|
||||
outfile = open("../out");
|
||||
# first read in the old stuff into the table...
|
||||
Input::add_event([$source="../conn", $name="conn", $fields=Conn::Info, $ev=line, $want_record=T, $reader=Input::READER_SQLITE, $config=config_strings]);
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,6 @@ event bro_init()
|
|||
};
|
||||
|
||||
outfile = open("../out");
|
||||
# first read in the old stuff into the table...
|
||||
Input::add_event([$source="../port", $name="port", $fields=Val, $ev=line, $reader=Input::READER_SQLITE, $want_record=F, $config=config_strings]);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue