mirror of
https://github.com/zeek/zeek.git
synced 2025-10-07 17:18:20 +00:00
Merge remote-tracking branch 'origin/fastpath'
* origin/fastpath: Fix memory leak when processing a thread's input message fails. add comparator functor to the info maps of readerbackend and readerwriteend. Fix initialization of WriterFrontend names.
This commit is contained in:
commit
9e97f7c2aa
5 changed files with 17 additions and 6 deletions
|
@ -74,7 +74,7 @@ public:
|
|||
struct ReaderInfo
|
||||
{
|
||||
// Structure takes ownership of the strings.
|
||||
typedef std::map<const char*, const char*> config_map;
|
||||
typedef std::map<const char*, const char*, CompareString> config_map;
|
||||
|
||||
/**
|
||||
* A string left to the interpretation of the reader
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
struct WriterInfo
|
||||
{
|
||||
// Structure takes ownership of these strings.
|
||||
typedef std::map<const char*, const char*> config_map;
|
||||
typedef std::map<const char*, const char*, CompareString> config_map;
|
||||
|
||||
/**
|
||||
* A string left to the interpretation of the writer
|
||||
|
|
|
@ -112,7 +112,7 @@ WriterFrontend::WriterFrontend(const WriterBackend::WriterInfo& arg_info, EnumVa
|
|||
write_buffer_pos = 0;
|
||||
info = new WriterBackend::WriterInfo(arg_info);
|
||||
|
||||
const char* w = arg_writer->Type()->AsEnumType()->Lookup(arg_stream->InternalInt());
|
||||
const char* w = arg_writer->Type()->AsEnumType()->Lookup(arg_writer->InternalInt());
|
||||
name = copy_string(fmt("%s/%s", arg_info.path, w));
|
||||
|
||||
if ( local )
|
||||
|
|
|
@ -342,14 +342,14 @@ void MsgThread::Run()
|
|||
|
||||
bool result = msg->Process();
|
||||
|
||||
delete msg;
|
||||
|
||||
if ( ! result )
|
||||
{
|
||||
string s = Fmt("%s failed, terminating thread (MsgThread)", Name());
|
||||
Error(s.c_str());
|
||||
break;
|
||||
}
|
||||
|
||||
delete msg;
|
||||
}
|
||||
|
||||
// In case we haven't send the finish method yet, do it now. Reading
|
||||
|
|
11
src/util.h
11
src/util.h
|
@ -346,4 +346,15 @@ inline int safe_vsnprintf(char* str, size_t size, const char* format, va_list al
|
|||
extern void get_memory_usage(unsigned int* total,
|
||||
unsigned int* malloced);
|
||||
|
||||
// Class to be used as a third argument for STL maps to be able to use
|
||||
// char*'s as keys. Otherwise the pointer values will be compared instead of
|
||||
// the actual string values.
|
||||
struct CompareString
|
||||
{
|
||||
bool operator()(char const *a, char const *b) const
|
||||
{
|
||||
return std::strcmp(a, b) < 0;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue