mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 05:45:59 +03:00
refactoring and remove dead code in lmdb
This commit is contained in:
parent
3951ba0e48
commit
dc6cce5f0c
@ -45,7 +45,6 @@ class Collection {
|
|||||||
public:
|
public:
|
||||||
explicit Collection(const std::string &a) : m_name(a) { }
|
explicit Collection(const std::string &a) : m_name(a) { }
|
||||||
virtual ~Collection() { }
|
virtual ~Collection() { }
|
||||||
virtual void store(std::string key, std::string value) = 0;
|
|
||||||
|
|
||||||
virtual bool storeOrUpdateFirst(const std::string &key,
|
virtual bool storeOrUpdateFirst(const std::string &key,
|
||||||
const std::string &value) = 0;
|
const std::string &value) = 0;
|
||||||
@ -70,21 +69,6 @@ class Collection {
|
|||||||
variables::KeyExclusions &ke) = 0;
|
variables::KeyExclusions &ke) = 0;
|
||||||
|
|
||||||
|
|
||||||
/* store */
|
|
||||||
virtual void store(std::string key, std::string compartment,
|
|
||||||
std::string value) {
|
|
||||||
std::string nkey = compartment + "::" + key;
|
|
||||||
store(nkey, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
virtual void store(std::string key, std::string compartment,
|
|
||||||
std::string compartment2, std::string value) {
|
|
||||||
std::string nkey = compartment + "::" + compartment2 + "::" + key;
|
|
||||||
store(nkey, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* storeOrUpdateFirst */
|
/* storeOrUpdateFirst */
|
||||||
virtual bool storeOrUpdateFirst(const std::string &key,
|
virtual bool storeOrUpdateFirst(const std::string &key,
|
||||||
std::string compartment, const std::string &value) {
|
std::string compartment, const std::string &value) {
|
||||||
|
@ -76,7 +76,7 @@ class InMemoryPerProcess :
|
|||||||
public:
|
public:
|
||||||
explicit InMemoryPerProcess(const std::string &name);
|
explicit InMemoryPerProcess(const std::string &name);
|
||||||
~InMemoryPerProcess();
|
~InMemoryPerProcess();
|
||||||
void store(std::string key, std::string value) override;
|
void store(std::string key, std::string value);
|
||||||
|
|
||||||
bool storeOrUpdateFirst(const std::string &key,
|
bool storeOrUpdateFirst(const std::string &key,
|
||||||
const std::string &value) override;
|
const std::string &value) override;
|
||||||
@ -101,6 +101,20 @@ class InMemoryPerProcess :
|
|||||||
std::vector<const VariableValue *> *l,
|
std::vector<const VariableValue *> *l,
|
||||||
variables::KeyExclusions &ke) override;
|
variables::KeyExclusions &ke) override;
|
||||||
|
|
||||||
|
/* store */
|
||||||
|
virtual void store(std::string key, std::string compartment,
|
||||||
|
std::string value) {
|
||||||
|
std::string nkey = compartment + "::" + key;
|
||||||
|
store(nkey, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
virtual void store(std::string key, std::string compartment,
|
||||||
|
std::string compartment2, std::string value) {
|
||||||
|
std::string nkey = compartment + "::" + compartment2 + "::" + key;
|
||||||
|
store(nkey, value);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
pthread_mutex_t m_lock;
|
pthread_mutex_t m_lock;
|
||||||
};
|
};
|
||||||
|
@ -397,43 +397,6 @@ end_txn:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LMDB::store(std::string key, std::string value) {
|
|
||||||
MDB_val mdb_key, mdb_data;
|
|
||||||
MDB_txn *txn = NULL;
|
|
||||||
int rc;
|
|
||||||
MDB_stat mst;
|
|
||||||
|
|
||||||
rc = txn_begin(0, &txn);
|
|
||||||
lmdb_debug(rc, "txn", "store");
|
|
||||||
if (rc != 0) {
|
|
||||||
goto end_txn;
|
|
||||||
}
|
|
||||||
|
|
||||||
string2val(key, &mdb_key);
|
|
||||||
string2val(value, &mdb_data);
|
|
||||||
rc = mdb_put(txn, m_dbi, &mdb_key, &mdb_data, 0);
|
|
||||||
lmdb_debug(rc, "put", "store");
|
|
||||||
if (rc != 0) {
|
|
||||||
goto end_put;
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = mdb_txn_commit(txn);
|
|
||||||
lmdb_debug(rc, "commit", "store");
|
|
||||||
if (rc != 0) {
|
|
||||||
goto end_commit;
|
|
||||||
}
|
|
||||||
|
|
||||||
end_put:
|
|
||||||
end_dbi:
|
|
||||||
if (rc != 0) {
|
|
||||||
mdb_txn_abort(txn);
|
|
||||||
}
|
|
||||||
end_commit:
|
|
||||||
end_txn:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool LMDB::updateFirst(const std::string &key,
|
bool LMDB::updateFirst(const std::string &key,
|
||||||
const std::string &value) {
|
const std::string &value) {
|
||||||
int rc;
|
int rc;
|
||||||
|
@ -98,7 +98,6 @@ class LMDB :
|
|||||||
public Collection {
|
public Collection {
|
||||||
public:
|
public:
|
||||||
explicit LMDB(const std::string &name);
|
explicit LMDB(const std::string &name);
|
||||||
void store(std::string key, std::string value) override;
|
|
||||||
|
|
||||||
bool storeOrUpdateFirst(const std::string &key,
|
bool storeOrUpdateFirst(const std::string &key,
|
||||||
const std::string &value) override;
|
const std::string &value) override;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user