summaryrefslogtreecommitdiff
path: root/modules/database
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2013-02-13 11:00:27 -0500
committerAdam <Adam@anope.org>2013-02-14 01:20:18 -0500
commit994866461c44d57e9b1dd1813283185230c2da45 (patch)
tree14ee4feaf044c6e62c1ab70f561d066a1f334a11 /modules/database
parentfc4b884d0ea7549e5b63cd9e3c13a29aa8627c24 (diff)
Update obj ts when constructed in db_sql
Diffstat (limited to 'modules/database')
-rw-r--r--modules/database/db_sql.cpp10
-rw-r--r--modules/database/db_sql_live.cpp13
2 files changed, 13 insertions, 10 deletions
diff --git a/modules/database/db_sql.cpp b/modules/database/db_sql.cpp
index a9bcdf0e8..170f7a5c8 100644
--- a/modules/database/db_sql.cpp
+++ b/modules/database/db_sql.cpp
@@ -59,7 +59,7 @@ class DBSQL : public Module, public Pipe
ServiceReference<Provider> sql;
SQLSQLInterface sqlinterface;
Anope::string prefix;
- std::set<Reference<Serializable> > updated_items;
+ std::set<Serializable *> updated_items;
bool shutting_down;
bool loading_databases;
bool loaded;
@@ -98,11 +98,11 @@ class DBSQL : public Module, public Pipe
void OnNotify() anope_override
{
- for (std::set<Reference<Serializable> >::iterator it = this->updated_items.begin(), it_end = this->updated_items.end(); it != it_end; ++it)
+ for (std::set<Serializable *>::iterator it = this->updated_items.begin(), it_end = this->updated_items.end(); it != it_end; ++it)
{
- Reference<Serializable> obj = *it;
+ Serializable *obj = *it;
- if (obj && this->sql)
+ if (this->sql)
{
Data *data = new Data();
obj->Serialize(*data);
@@ -177,6 +177,7 @@ class DBSQL : public Module, public Pipe
{
if (this->shutting_down || this->loading_databases)
return;
+ obj->UpdateTS();
this->updated_items.insert(obj);
this->Notify();
}
@@ -186,6 +187,7 @@ class DBSQL : public Module, public Pipe
Serialize::Type *s_type = obj->GetSerializableType();
if (s_type)
this->RunBackground("DELETE FROM `" + this->prefix + s_type->GetName() + "` WHERE `id` = " + stringify(obj->id));
+ this->updated_items.erase(obj);
}
void OnSerializableUpdate(Serializable *obj) anope_override
diff --git a/modules/database/db_sql_live.cpp b/modules/database/db_sql_live.cpp
index aec84c8ef..03de09294 100644
--- a/modules/database/db_sql_live.cpp
+++ b/modules/database/db_sql_live.cpp
@@ -13,7 +13,7 @@ class DBMySQL : public Module, public Pipe
time_t lastwarn;
bool ro;
bool init;
- std::set<Reference<Serializable> > updated_items;
+ std::set<Serializable *> updated_items;
bool CheckSQL()
{
@@ -83,9 +83,9 @@ class DBMySQL : public Module, public Pipe
if (!this->CheckInit())
return;
- for (std::set<Reference<Serializable> >::iterator it = this->updated_items.begin(), it_end = this->updated_items.end(); it != it_end; ++it)
+ for (std::set<Serializable *>::iterator it = this->updated_items.begin(), it_end = this->updated_items.end(); it != it_end; ++it)
{
- Reference<Serializable> obj = *it;
+ Serializable *obj = *it;
if (obj && this->SQL)
{
@@ -144,6 +144,7 @@ class DBMySQL : public Module, public Pipe
{
if (!this->CheckInit())
return;
+ obj->UpdateTS();
this->updated_items.insert(obj);
this->Notify();
}
@@ -153,10 +154,10 @@ class DBMySQL : public Module, public Pipe
if (!this->CheckInit())
return;
Serialize::Type *s_type = obj->GetSerializableType();
- if (!s_type)
- return;
- this->RunQuery("DELETE FROM `" + this->prefix + s_type->GetName() + "` WHERE `id` = " + stringify(obj->id));
+ if (s_type)
+ this->RunQuery("DELETE FROM `" + this->prefix + s_type->GetName() + "` WHERE `id` = " + stringify(obj->id));
s_type->objects.erase(obj->id);
+ this->updated_items.erase(obj);
}
void OnSerializeCheck(Serialize::Type *obj) anope_override