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
|
struct ReaderInfo
|
||||||
{
|
{
|
||||||
// Structure takes ownership of the strings.
|
// 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
|
* A string left to the interpretation of the reader
|
||||||
|
|
|
@ -49,7 +49,7 @@ public:
|
||||||
struct WriterInfo
|
struct WriterInfo
|
||||||
{
|
{
|
||||||
// Structure takes ownership of these strings.
|
// 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
|
* 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;
|
write_buffer_pos = 0;
|
||||||
info = new WriterBackend::WriterInfo(arg_info);
|
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));
|
name = copy_string(fmt("%s/%s", arg_info.path, w));
|
||||||
|
|
||||||
if ( local )
|
if ( local )
|
||||||
|
|
|
@ -342,14 +342,14 @@ void MsgThread::Run()
|
||||||
|
|
||||||
bool result = msg->Process();
|
bool result = msg->Process();
|
||||||
|
|
||||||
|
delete msg;
|
||||||
|
|
||||||
if ( ! result )
|
if ( ! result )
|
||||||
{
|
{
|
||||||
string s = Fmt("%s failed, terminating thread (MsgThread)", Name());
|
string s = Fmt("%s failed, terminating thread (MsgThread)", Name());
|
||||||
Error(s.c_str());
|
Error(s.c_str());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete msg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// In case we haven't send the finish method yet, do it now. Reading
|
// In case we haven't send the finish method yet, do it now. Reading
|
||||||
|
|
13
src/util.h
13
src/util.h
|
@ -135,7 +135,7 @@ extern const char* fmt_access_time(double time);
|
||||||
extern bool ensure_dir(const char *dirname);
|
extern bool ensure_dir(const char *dirname);
|
||||||
|
|
||||||
// Returns true if path exists and is a directory.
|
// Returns true if path exists and is a directory.
|
||||||
bool is_dir(const char* path);
|
bool is_dir(const char* path);
|
||||||
|
|
||||||
extern uint8 shared_hmac_md5_key[16];
|
extern uint8 shared_hmac_md5_key[16];
|
||||||
|
|
||||||
|
@ -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,
|
extern void get_memory_usage(unsigned int* total,
|
||||||
unsigned int* malloced);
|
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
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue