Browse Source

Fixed a bug in scanMessageFile where the XHDRInjectOn flag was being interpreted before it had been set by the configuration This caused large messages to be rewritten shorter than they needed to be when header injection was turned on because the flag would appear to be off and the MessageFileSize would be recalculated downward. Later, after the flag was set, the headers would be injected into the shortened file.

Added a function to snf_RulebaseHandler that safely peeks at the current configuration to facilitate the above bug fix.

Bumbed the minor revision number for the engine.


git-svn-id: https://svn.microneil.com/svn/SNFMulti/trunk@44 dc71a809-1921-45c4-985c-09c81d0142d9
wx
madscientist 12 years ago
parent
commit
e5fc208746
2 changed files with 25 additions and 5 deletions
  1. 23
    4
      SNFMulti.cpp
  2. 2
    1
      SNFMulti.hpp

+ 23
- 4
SNFMulti.cpp View File

@@ -23,7 +23,7 @@ using namespace std;

//// Version Info

const char* SNF_ENGINE_VERSION = "SNFMulti Engine Version 3.0.22 Build: " __DATE__ " " __TIME__;
const char* SNF_ENGINE_VERSION = "SNFMulti Engine Version 3.0.23 Build: " __DATE__ " " __TIME__;

//// Script Caller Methods

@@ -932,6 +932,25 @@ enum PatternResultTypes {
IPPattern,
AboveBandPattern
};
// In order to optimize message file reads when header injection is not activated
// we need to look ahead to see if header injection is likely to be turned on when
// we do the scan. This is a short term fix. The better fix might be to perform
// the configuration load prior to scanning the message -- but that is a much larger
// refactoring that ties up configuration and rulebase resources for a longer time.
// Instead we're going to take an optimistic route and just peek at the configuration.
// If the configuration changes while we're loading the file to be scanned then
// we have two cases. If we go from XHDRInject off to XHDRInject on then we will
// miss adding headers to the message - not a bad outcome. If we go from XHDRInject
// on to XHDRInject off then we might emit headers for an extra message - also not
// a bad outcome.
bool snf_RulebaseHandler::testXHDRInjectOn() {
ScopeMutex HoldStillPlease(MyMutex); // Lock the rulebase until we're done.
snfCFGData* myCFG = MyCFGmgr.ActiveConfiguration(); // Grab the active configuration.
bool myXHDRInjectOnFlag = (LogOutputMode_Inject == myCFG->XHDROutput_Mode); // True if output mode is inject.
return myXHDRInjectOnFlag; // return the result.
}

int snf_EngineHandler::scanMessageFile( // Scan this message file.
const string MessageFilePath, // -- this is the file path (and id)
@@ -983,9 +1002,9 @@ int snf_EngineHandler::scanMessageFile(
throw FileError("snf_EngineHandler::scanMessageFile() FileEmpty!");
}
bool isXHeaderInjectionOn = (MyScanData.XHeaderInjectOn);
bool isNoNeedToReadFullFile = (false == isXHeaderInjectionOn);
if(isNoNeedToReadFullFile) {
bool isXHeaderInjectionOn = MyRulebase->testXHDRInjectOn();
bool noNeedToReadFullFile = (false == isXHeaderInjectionOn);
if(noNeedToReadFullFile) {
MessageFileSize = min(MessageFileSize, snf_ScanHorizon);
}


+ 2
- 1
SNFMulti.hpp View File

@@ -266,7 +266,8 @@ class snf_RulebaseHandler {

int Generation(); // Returns the generation number.

void addRulePanic(int RuleID); // Synchronously add a RulePanic.
void addRulePanic(int RuleID); // Synchronously add a RulePanic.
bool testXHDRInjectOn(); // Safely look ahead at XHDRInjectOn.

IPTestRecord& performIPTest(IPTestRecord& I); // Perform an IP test.
void logThisIPTest(IPTestRecord& I, string Action); // Log an IP test result & action.

Loading…
Cancel
Save