mirror of
https://github.com/zeek/zeek.git
synced 2025-10-12 11:38:20 +00:00
Merge remote-tracking branch 'origin/topic/bernhard/input-update'
Closes #1021. * origin/topic/bernhard/input-update: this event handler fails the unused-event-handlers test because it is a bit of a special case. ...and fix the event ordering issue. Dispatch != QueueEvent add Terminate to input framework to prevent potential shutdown race-conditions. fix warning. fix stderr test. ls behaves differently on errors on linux... small fixes. linux does not have strnstr and close only fds that are currently open (the logging framework really did not like that :) ) A bunch of more changes for the raw reader make reading from stdout and stderr simultaneously work. allow sending data to stdin of child process Streaming reads from external commands work without blocking anything. replace popen with fork and exec. change raw reader to use basic c io instead of fdstream encapsulation class.
This commit is contained in:
commit
96fe05633a
29 changed files with 946 additions and 277 deletions
|
@ -320,6 +320,7 @@ bool Manager::CreateStream(Stream* info, RecordVal* description)
|
|||
|
||||
ReaderBackend::ReaderInfo* rinfo = new ReaderBackend::ReaderInfo();
|
||||
rinfo->source = copy_string(source.c_str());
|
||||
rinfo->name = copy_string(name.c_str());
|
||||
|
||||
EnumVal* mode = description->LookupWithDefault(rtype->FieldOffset("mode"))->AsEnumVal();
|
||||
switch ( mode->InternalInt() )
|
||||
|
@ -1241,6 +1242,9 @@ void Manager::EndCurrentSend(ReaderFrontend* reader)
|
|||
|
||||
if ( i->stream_type != TABLE_STREAM )
|
||||
{
|
||||
#ifdef DEBUG
|
||||
DBG_LOG(DBG_INPUT, "%s is event, sending end of data", i->name.c_str());
|
||||
#endif
|
||||
// just signal the end of the data source
|
||||
SendEndOfData(i);
|
||||
return;
|
||||
|
@ -1345,8 +1349,13 @@ void Manager::SendEndOfData(ReaderFrontend* reader)
|
|||
SendEndOfData(i);
|
||||
}
|
||||
|
||||
|
||||
void Manager::SendEndOfData(const Stream *i)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
DBG_LOG(DBG_INPUT, "SendEndOfData for stream %s",
|
||||
i->name.c_str());
|
||||
#endif
|
||||
SendEvent(end_of_data, 2, new StringVal(i->name.c_str()), new StringVal(i->info->source));
|
||||
|
||||
if ( i->stream_type == ANALYSIS_STREAM )
|
||||
|
@ -1362,6 +1371,11 @@ void Manager::Put(ReaderFrontend* reader, Value* *vals)
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
DBG_LOG(DBG_INPUT, "Put for stream %s",
|
||||
i->name.c_str());
|
||||
#endif
|
||||
|
||||
int readFields = 0;
|
||||
|
||||
if ( i->stream_type == TABLE_STREAM )
|
||||
|
@ -1700,6 +1714,11 @@ bool Manager::SendEvent(const string& name, const int num_vals, Value* *vals)
|
|||
return false;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
DBG_LOG(DBG_INPUT, "SendEvent for event %s with num_vals vals",
|
||||
name.c_str(), num_vals);
|
||||
#endif
|
||||
|
||||
RecordType *type = handler->FType()->Args();
|
||||
int num_event_vals = type->NumFields();
|
||||
if ( num_vals != num_event_vals )
|
||||
|
@ -1712,7 +1731,7 @@ bool Manager::SendEvent(const string& name, const int num_vals, Value* *vals)
|
|||
for ( int i = 0; i < num_vals; i++)
|
||||
vl->append(ValueToVal(vals[i], type->FieldType(i)));
|
||||
|
||||
mgr.Dispatch(new Event(handler, vl));
|
||||
mgr.QueueEvent(handler, vl, SOURCE_LOCAL);
|
||||
|
||||
for ( int i = 0; i < num_vals; i++ )
|
||||
delete vals[i];
|
||||
|
@ -1726,6 +1745,11 @@ void Manager::SendEvent(EventHandlerPtr ev, const int numvals, ...)
|
|||
{
|
||||
val_list* vl = new val_list;
|
||||
|
||||
#ifdef DEBUG
|
||||
DBG_LOG(DBG_INPUT, "SendEvent with %d vals",
|
||||
numvals);
|
||||
#endif
|
||||
|
||||
va_list lP;
|
||||
va_start(lP, numvals);
|
||||
for ( int i = 0; i < numvals; i++ )
|
||||
|
@ -1740,6 +1764,11 @@ void Manager::SendEvent(EventHandlerPtr ev, list<Val*> events)
|
|||
{
|
||||
val_list* vl = new val_list;
|
||||
|
||||
#ifdef DEBUG
|
||||
DBG_LOG(DBG_INPUT, "SendEvent with %d vals (list)",
|
||||
events.size());
|
||||
#endif
|
||||
|
||||
for ( list<Val*>::iterator i = events.begin(); i != events.end(); i++ )
|
||||
{
|
||||
vl->append( *i );
|
||||
|
@ -2244,3 +2273,18 @@ Manager::Stream* Manager::FindStream(ReaderFrontend* reader)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Function is called on Bro shutdown.
|
||||
// Signal all frontends that they will cease operation.
|
||||
void Manager::Terminate()
|
||||
{
|
||||
for ( map<ReaderFrontend*, Stream*>::iterator i = readers.begin(); i != readers.end(); ++i )
|
||||
{
|
||||
if ( i->second->removed )
|
||||
continue;
|
||||
|
||||
i->second->removed = true;
|
||||
i->second->reader->Stop();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue