mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-11-16 01:22:18 +03:00
Removes reference counter for RulesSet
This commit is contained in:
@@ -48,25 +48,20 @@ class RulesSet : public RulesSetProperties {
|
||||
public:
|
||||
RulesSet()
|
||||
: RulesSetProperties(new DebugLog()),
|
||||
unicode_codepage(0),
|
||||
#ifndef NO_LOGS
|
||||
m_secmarker_skipped(0),
|
||||
#endif
|
||||
m_referenceCount(0) { }
|
||||
unicode_codepage(0) { }
|
||||
|
||||
explicit RulesSet(DebugLog *customLog)
|
||||
: RulesSetProperties(customLog),
|
||||
unicode_codepage(0),
|
||||
#ifndef NO_LOGS
|
||||
m_secmarker_skipped(0),
|
||||
#endif
|
||||
m_referenceCount(0) { }
|
||||
unicode_codepage(0) { }
|
||||
|
||||
~RulesSet() { }
|
||||
|
||||
void incrementReferenceCount(void);
|
||||
void decrementReferenceCount(void);
|
||||
|
||||
int loadFromUri(const char *uri);
|
||||
int loadRemote(const char *key, const char *uri);
|
||||
int load(const char *rules);
|
||||
@@ -87,7 +82,6 @@ class RulesSet : public RulesSetProperties {
|
||||
|
||||
RulesSetPhases m_rulesSetPhases;
|
||||
private:
|
||||
int m_referenceCount;
|
||||
#ifndef NO_LOGS
|
||||
uint8_t m_secmarker_skipped;
|
||||
#endif
|
||||
|
||||
@@ -31,51 +31,6 @@ using modsecurity::Utils::HttpsClient;
|
||||
namespace modsecurity {
|
||||
|
||||
|
||||
/**
|
||||
* @name incrementReferenceCount
|
||||
* @brief Increment the number of transactions using this class
|
||||
* @ingroup ModSecCore
|
||||
*
|
||||
* At certain point it is expected to have two differnt
|
||||
* groups of rules attached to a specific core, this happens
|
||||
* for instance when a webserver is reloading its
|
||||
* configurations, the old configurations/rules is available
|
||||
* for the old connections and the new rules are available
|
||||
* for the newest connections.
|
||||
*
|
||||
* @return Number of the current transactions using this rules
|
||||
*
|
||||
*/
|
||||
void RulesSet::incrementReferenceCount(void) {
|
||||
this->m_referenceCount++;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @name decrementReferenceCount
|
||||
* @brief Decrement the number of transactions using this class
|
||||
* @ingroup ModSecCore
|
||||
*
|
||||
* @return Number of the current transactions using this rules
|
||||
*
|
||||
*/
|
||||
void RulesSet::decrementReferenceCount(void) {
|
||||
this->m_referenceCount--;
|
||||
if (this->m_referenceCount == 0) {
|
||||
/**
|
||||
* FIXME: If there are new rules loaded (new instance
|
||||
* of this class) and the reference is zero, we
|
||||
* can delete this instance freeing some memory.
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* std::cout << "We may want to delete this rules instance" \
|
||||
* << std::endl;
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @name loadFromUri
|
||||
* @brief load rules from a give uri
|
||||
|
||||
@@ -134,7 +134,6 @@ Transaction::Transaction(ModSecurity *ms, RulesSet *rules, void *logCbData)
|
||||
TransactionAnchoredVariables(this) {
|
||||
m_id = std::to_string(this->m_timeStamp) + \
|
||||
std::to_string(modsecurity::utils::generate_transaction_unique_id());
|
||||
m_rules->incrementReferenceCount();
|
||||
|
||||
m_variableUrlEncodedError.set("0", 0);
|
||||
|
||||
@@ -177,7 +176,6 @@ Transaction::Transaction(ModSecurity *ms, RulesSet *rules, char *id, void *logCb
|
||||
#endif
|
||||
TransactionAnchoredVariables(this) {
|
||||
m_id = std::string(id);
|
||||
m_rules->incrementReferenceCount();
|
||||
|
||||
m_variableUrlEncodedError.set("0", 0);
|
||||
|
||||
@@ -196,8 +194,6 @@ Transaction::~Transaction() {
|
||||
|
||||
m_rulesMessages.clear();
|
||||
|
||||
m_rules->decrementReferenceCount();
|
||||
|
||||
intervention::free(&m_it);
|
||||
intervention::clean(&m_it);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user