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:
Bernhard Amann 2013-01-16 18:13:39 -08:00
parent 8f71186bf7
commit 0fcc3db9a0
10 changed files with 33 additions and 7 deletions

View file

@ -2,4 +2,4 @@
@load ./readers/ascii @load ./readers/ascii
@load ./readers/raw @load ./readers/raw
@load ./readers/benchmark @load ./readers/benchmark
@load ./readers/sqlite

View file

@ -9,5 +9,9 @@ export {
## String to use for an unset &optional field. ## String to use for an unset &optional field.
const unset_field = Log::unset_field &redef; 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;
} }

View file

@ -57,3 +57,8 @@ const autospread: double;
const addfactor: count; const addfactor: count;
const stopspreadat: count; const stopspreadat: count;
const timedspread: double; const timedspread: double;
module InputSQLite;
const set_separator: string;
const unset_field: string;
const empty_field: string;

View file

@ -22,7 +22,17 @@ using threading::Field;
SQLite::SQLite(ReaderFrontend *frontend) : ReaderBackend(frontend) 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() SQLite::~SQLite()

View file

@ -47,6 +47,9 @@ private:
sqlite3 *db; sqlite3 *db;
sqlite3_stmt *st; sqlite3_stmt *st;
AsciiInputOutput* io; AsciiInputOutput* io;
string set_separator;
string unset_field;
}; };

View file

@ -87,6 +87,7 @@ const num_threads: count;
module LogSQLite; module LogSQLite;
const set_separator: string; const set_separator: string;
const empty_field: string;
const unset_field: string; const unset_field: string;
# Options for the ElasticSearch writer. # Options for the ElasticSearch writer.

View file

@ -30,9 +30,14 @@ SQLite::SQLite(WriterFrontend* frontend) : WriterBackend(frontend)
BifConst::LogAscii::unset_field->Len() BifConst::LogAscii::unset_field->Len()
); );
empty_field.assign(
(const char*) BifConst::LogAscii::empty_field->Bytes(),
BifConst::LogAscii::empty_field->Len()
);
db = 0; 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() SQLite::~SQLite()
@ -134,7 +139,7 @@ bool SQLite::DoInit(const WriterInfo& info, int num_fields,
&db, &db,
SQLITE_OPEN_READWRITE | SQLITE_OPEN_READWRITE |
SQLITE_OPEN_CREATE | SQLITE_OPEN_CREATE |
SQLITE_OPEN_FULLMUTEX // perhaps change to nomutex SQLITE_OPEN_NOMUTEX // perhaps change to nomutex
, ,
NULL)) ) NULL)) )
return false; return false;

View file

@ -46,9 +46,9 @@ private:
sqlite3 *db; sqlite3 *db;
sqlite3_stmt *st; sqlite3_stmt *st;
string separator;
string set_separator; string set_separator;
string unset_field; string unset_field;
string empty_field;
AsciiInputOutput* io; AsciiInputOutput* io;
}; };

View file

@ -86,7 +86,6 @@ event bro_init()
}; };
outfile = open("../out"); 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]); Input::add_event([$source="../conn", $name="conn", $fields=Conn::Info, $ev=line, $want_record=T, $reader=Input::READER_SQLITE, $config=config_strings]);
} }

View file

@ -36,7 +36,6 @@ event bro_init()
}; };
outfile = open("../out"); 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]); Input::add_event([$source="../port", $name="port", $fields=Val, $ev=line, $reader=Input::READER_SQLITE, $want_record=F, $config=config_strings]);
} }