Skip to content

Commit dc6cce5

Browse files
committed
refactoring and remove dead code in lmdb
1 parent 3951ba0 commit dc6cce5

File tree

4 files changed

+15
-55
lines changed

4 files changed

+15
-55
lines changed

headers/modsecurity/collection/collection.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ class Collection {
4545
public:
4646
explicit Collection(const std::string &a) : m_name(a) { }
4747
virtual ~Collection() { }
48-
virtual void store(std::string key, std::string value) = 0;
4948

5049
virtual bool storeOrUpdateFirst(const std::string &key,
5150
const std::string &value) = 0;
@@ -70,21 +69,6 @@ class Collection {
7069
variables::KeyExclusions &ke) = 0;
7170

7271

73-
/* store */
74-
virtual void store(std::string key, std::string compartment,
75-
std::string value) {
76-
std::string nkey = compartment + "::" + key;
77-
store(nkey, value);
78-
}
79-
80-
81-
virtual void store(std::string key, std::string compartment,
82-
std::string compartment2, std::string value) {
83-
std::string nkey = compartment + "::" + compartment2 + "::" + key;
84-
store(nkey, value);
85-
}
86-
87-
8872
/* storeOrUpdateFirst */
8973
virtual bool storeOrUpdateFirst(const std::string &key,
9074
std::string compartment, const std::string &value) {

src/collection/backend/in_memory-per_process.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class InMemoryPerProcess :
7676
public:
7777
explicit InMemoryPerProcess(const std::string &name);
7878
~InMemoryPerProcess();
79-
void store(std::string key, std::string value) override;
79+
void store(std::string key, std::string value);
8080

8181
bool storeOrUpdateFirst(const std::string &key,
8282
const std::string &value) override;
@@ -101,6 +101,20 @@ class InMemoryPerProcess :
101101
std::vector<const VariableValue *> *l,
102102
variables::KeyExclusions &ke) override;
103103

104+
/* store */
105+
virtual void store(std::string key, std::string compartment,
106+
std::string value) {
107+
std::string nkey = compartment + "::" + key;
108+
store(nkey, value);
109+
}
110+
111+
112+
virtual void store(std::string key, std::string compartment,
113+
std::string compartment2, std::string value) {
114+
std::string nkey = compartment + "::" + compartment2 + "::" + key;
115+
store(nkey, value);
116+
}
117+
104118
private:
105119
pthread_mutex_t m_lock;
106120
};

src/collection/backend/lmdb.cc

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -397,43 +397,6 @@ void LMDB::resolveSingleMatch(const std::string& var,
397397
}
398398

399399

400-
void LMDB::store(std::string key, std::string value) {
401-
MDB_val mdb_key, mdb_data;
402-
MDB_txn *txn = NULL;
403-
int rc;
404-
MDB_stat mst;
405-
406-
rc = txn_begin(0, &txn);
407-
lmdb_debug(rc, "txn", "store");
408-
if (rc != 0) {
409-
goto end_txn;
410-
}
411-
412-
string2val(key, &mdb_key);
413-
string2val(value, &mdb_data);
414-
rc = mdb_put(txn, m_dbi, &mdb_key, &mdb_data, 0);
415-
lmdb_debug(rc, "put", "store");
416-
if (rc != 0) {
417-
goto end_put;
418-
}
419-
420-
rc = mdb_txn_commit(txn);
421-
lmdb_debug(rc, "commit", "store");
422-
if (rc != 0) {
423-
goto end_commit;
424-
}
425-
426-
end_put:
427-
end_dbi:
428-
if (rc != 0) {
429-
mdb_txn_abort(txn);
430-
}
431-
end_commit:
432-
end_txn:
433-
return;
434-
}
435-
436-
437400
bool LMDB::updateFirst(const std::string &key,
438401
const std::string &value) {
439402
int rc;

src/collection/backend/lmdb.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ class LMDB :
9898
public Collection {
9999
public:
100100
explicit LMDB(const std::string &name);
101-
void store(std::string key, std::string value) override;
102101

103102
bool storeOrUpdateFirst(const std::string &key,
104103
const std::string &value) override;

0 commit comments

Comments
 (0)