mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 23:58:20 +00:00
Review usage of Reporter::InternalError, addresses BIT-1045.
Replaced some with InternalWarning or InternalAnalyzerError, the later being a new method which signals the analyzer to not process further input. Some usages I just removed if they didn't make sense or clearly couldn't happen. Also did some minor refactors of related code while reviewing/exploring ways to get rid of InternalError usages. Also, for TCP content file write failures there's a new event: "contents_file_write_failure".
This commit is contained in:
parent
6734260136
commit
b828a6ddc7
51 changed files with 532 additions and 267 deletions
56
src/File.cc
56
src/File.cc
|
@ -281,8 +281,13 @@ FILE* BroFile::File()
|
|||
|
||||
FILE* BroFile::BringIntoCache()
|
||||
{
|
||||
char buf[256];
|
||||
|
||||
if ( f )
|
||||
reporter->InternalError("BroFile non-nil non-open file");
|
||||
{
|
||||
reporter->InternalWarning("BroFile non-nil non-open file");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( num_files_in_cache >= max_files_in_cache )
|
||||
PurgeCache();
|
||||
|
@ -296,22 +301,30 @@ FILE* BroFile::BringIntoCache()
|
|||
|
||||
if ( ! f )
|
||||
{
|
||||
reporter->Error("can't open %s", name);
|
||||
strerror_r(errno, buf, sizeof(buf));
|
||||
reporter->Error("can't open %s: %s", name, buf);
|
||||
|
||||
f = fopen("/dev/null", "w");
|
||||
|
||||
if ( ! f )
|
||||
reporter->InternalError("out of file descriptors");
|
||||
if ( f )
|
||||
{
|
||||
okay_to_manage = 0;
|
||||
return f;
|
||||
}
|
||||
|
||||
okay_to_manage = 0;
|
||||
return f;
|
||||
strerror_r(errno, buf, sizeof(buf));
|
||||
reporter->InternalWarning("can't open /dev/null: %s", buf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
RaiseOpenEvent();
|
||||
UpdateFileSize();
|
||||
|
||||
if ( fseek(f, position, SEEK_SET) < 0 )
|
||||
reporter->Error("reopen seek failed");
|
||||
{
|
||||
strerror_r(errno, buf, sizeof(buf));
|
||||
reporter->Error("reopen seek failed: %s", buf);
|
||||
}
|
||||
|
||||
InsertAtBeginning();
|
||||
|
||||
|
@ -386,18 +399,30 @@ int BroFile::Close()
|
|||
void BroFile::Suspend()
|
||||
{
|
||||
if ( ! is_in_cache )
|
||||
reporter->InternalError("BroFile::Suspend() called for non-cached file");
|
||||
{
|
||||
reporter->InternalWarning("BroFile::Suspend() called for non-cached file");
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! is_open )
|
||||
reporter->InternalError("BroFile::Suspend() called for non-open file");
|
||||
{
|
||||
reporter->InternalWarning("BroFile::Suspend() called for non-open file");
|
||||
return;
|
||||
}
|
||||
|
||||
Unlink();
|
||||
|
||||
if ( ! f )
|
||||
reporter->InternalError("BroFile::Suspend() called for nil file");
|
||||
{
|
||||
reporter->InternalWarning("BroFile::Suspend() called for nil file");
|
||||
return;
|
||||
}
|
||||
|
||||
if ( (position = ftell(f)) < 0 )
|
||||
{
|
||||
reporter->Error("ftell failed");
|
||||
char buf[256];
|
||||
strerror_r(errno, buf, sizeof(buf));
|
||||
reporter->Error("ftell failed: %s", buf);
|
||||
position = 0;
|
||||
}
|
||||
|
||||
|
@ -407,10 +432,13 @@ void BroFile::Suspend()
|
|||
|
||||
void BroFile::PurgeCache()
|
||||
{
|
||||
if ( ! tail )
|
||||
reporter->InternalError("BroFile purge of empty cache");
|
||||
if ( tail )
|
||||
{
|
||||
tail->Suspend();
|
||||
return;
|
||||
}
|
||||
|
||||
tail->Suspend();
|
||||
reporter->InternalWarning("BroFile purge of empty cache");
|
||||
}
|
||||
|
||||
void BroFile::Unlink()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue