mirror of
https://github.com/anope/anope.git
synced 2026-07-04 05:03:11 +02:00
The timestamp column in SQL should actually be null sometimes, and fixed some valgrind errors with db_sql_live
This commit is contained in:
+16
-10
@@ -73,6 +73,22 @@ class Reference : public ReferenceBase
|
||||
ref->DelReference(this);
|
||||
}
|
||||
|
||||
inline Reference<T>& operator=(const Reference<T> &other)
|
||||
{
|
||||
if (this != &other)
|
||||
{
|
||||
if (*this)
|
||||
this->ref->DelReference(this);
|
||||
|
||||
this->ref = other.ref;
|
||||
this->invalid = other.invalid;
|
||||
|
||||
if (*this)
|
||||
this->ref->AddReference(this);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
/* We explicitly call operator bool here in several places to prevent other
|
||||
* operators, such operator T*, from being called instead, which will mess
|
||||
* with any class inheriting from this that overloads this operator.
|
||||
@@ -105,16 +121,6 @@ class Reference : public ReferenceBase
|
||||
return NULL;
|
||||
}
|
||||
|
||||
inline void operator=(T *newref)
|
||||
{
|
||||
if (operator bool())
|
||||
this->ref->DelReference(this);
|
||||
this->ref = newref;
|
||||
this->invalid = false;
|
||||
if (operator bool())
|
||||
this->ref->AddReference(this);
|
||||
}
|
||||
|
||||
inline bool operator<(const Reference<T> &other) const
|
||||
{
|
||||
return this < &other;
|
||||
|
||||
+28
-18
@@ -258,18 +258,34 @@ class Serialize::Reference : public ReferenceBase
|
||||
obj->AddReference(this);
|
||||
}
|
||||
|
||||
Reference(const Reference<T> &other) : ref(other.ref)
|
||||
Reference(const Reference<T> &other) : ReferenceBase(other), ref(other.ref)
|
||||
{
|
||||
if (*this)
|
||||
if (ref && !invalid)
|
||||
this->ref->AddReference(this);
|
||||
}
|
||||
|
||||
~Reference()
|
||||
{
|
||||
if (*this)
|
||||
if (ref && !invalid)
|
||||
this->ref->DelReference(this);
|
||||
}
|
||||
|
||||
inline Reference<T>& operator=(const Reference<T> &other)
|
||||
{
|
||||
if (this != &other)
|
||||
{
|
||||
if (ref && !invalid)
|
||||
this->ref->DelReference(this);
|
||||
|
||||
this->ref = other.ref;
|
||||
this->invalid = other.invalid;
|
||||
|
||||
if (ref && !invalid)
|
||||
this->ref->AddReference(this);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline operator bool() const
|
||||
{
|
||||
if (!this->invalid)
|
||||
@@ -277,25 +293,15 @@ class Serialize::Reference : public ReferenceBase
|
||||
return false;
|
||||
}
|
||||
|
||||
inline void operator=(T *newref)
|
||||
{
|
||||
if (*this)
|
||||
this->ref->DelReference(this);
|
||||
|
||||
this->ref = newref;
|
||||
this->invalid = false;
|
||||
|
||||
if (newref)
|
||||
this->ref->AddReference(this);
|
||||
}
|
||||
|
||||
inline operator T*() const
|
||||
{
|
||||
if (!this->invalid)
|
||||
{
|
||||
if (this->ref)
|
||||
// This can invalidate me
|
||||
this->ref->QueueUpdate();
|
||||
return this->ref;
|
||||
if (!this->invalid)
|
||||
return this->ref;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -305,8 +311,10 @@ class Serialize::Reference : public ReferenceBase
|
||||
if (!this->invalid)
|
||||
{
|
||||
if (this->ref)
|
||||
// This can invalidate me
|
||||
this->ref->QueueUpdate();
|
||||
return this->ref;
|
||||
if (!this->invalid)
|
||||
return this->ref;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -316,8 +324,10 @@ class Serialize::Reference : public ReferenceBase
|
||||
if (!this->invalid)
|
||||
{
|
||||
if (this->ref)
|
||||
// This can invalidate me
|
||||
this->ref->QueueUpdate();
|
||||
return this->ref;
|
||||
if (!this->invalid)
|
||||
return this->ref;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -192,8 +192,8 @@ class DBMySQL : public Module, public Pipe
|
||||
std::map<unsigned int, Serializable *>::iterator it = obj->objects.find(id);
|
||||
if (it != obj->objects.end())
|
||||
{
|
||||
it->second->Destroy();
|
||||
obj->objects.erase(it);
|
||||
it->second->Destroy(); // This also tries to remove this object from the map
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -372,7 +372,7 @@ std::vector<Query> MySQLService::CreateTable(const Anope::string &table, const D
|
||||
if (known_cols.empty())
|
||||
{
|
||||
Anope::string query_text = "CREATE TABLE `" + table + "` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT,"
|
||||
" `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP";
|
||||
" `timestamp` timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP";
|
||||
for (Data::Map::const_iterator it = data.data.begin(), it_end = data.data.end(); it != it_end; ++it)
|
||||
{
|
||||
known_cols.insert(it->first);
|
||||
|
||||
@@ -209,7 +209,7 @@ std::vector<Query> SQLiteService::CreateTable(const Anope::string &table, const
|
||||
|
||||
if (known_cols.empty())
|
||||
{
|
||||
Anope::string query_text = "CREATE TABLE `" + table + "` (`id` INTEGER PRIMARY KEY, `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP";
|
||||
Anope::string query_text = "CREATE TABLE `" + table + "` (`id` INTEGER PRIMARY KEY, `timestamp` timestamp DEFAULT CURRENT_TIMESTAMP";
|
||||
|
||||
for (Data::Map::const_iterator it = data.data.begin(), it_end = data.data.end(); it != it_end; ++it)
|
||||
{
|
||||
|
||||
+3
-2
@@ -88,10 +88,11 @@ void Serializable::Destroy()
|
||||
|
||||
void Serializable::QueueUpdate()
|
||||
{
|
||||
/* Check for modifications now */
|
||||
FOREACH_MOD(I_OnSerializeCheck, OnSerializeCheck(this->GetSerializableType()));
|
||||
/* Schedule updater */
|
||||
FOREACH_MOD(I_OnSerializableUpdate, OnSerializableUpdate(this));
|
||||
|
||||
/* Check for modifications now - this can delete this object! */
|
||||
FOREACH_MOD(I_OnSerializeCheck, OnSerializeCheck(this->GetSerializableType()));
|
||||
}
|
||||
|
||||
bool Serializable::IsCached(Serialize::Data *data)
|
||||
|
||||
Reference in New Issue
Block a user