diff options
author | Adam <Adam@anope.org> | 2011-01-07 15:57:13 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2011-01-07 15:57:13 -0500 |
commit | 44038491264a350a8849e1d7e8547bbdec134d74 (patch) | |
tree | 08b3b18d0ff4a4d814e638a882916c07882e16de /src | |
parent | 9efebe5461fd5985190380d11fd8c3c7a5fba9d6 (diff) |
Added db_mysql_live which allows Anope to pull data
from the four main SQL tables in realtime, which
effectively gives us "live" SQL.
Changed eventfd pipe engine to not use buffered write.
Added TryLock to threading engines.
Made blocking SQL queries in our SQL API thread-safe.
Diffstat (limited to 'src')
-rw-r--r-- | src/botserv.cpp | 11 | ||||
-rw-r--r-- | src/chanserv.cpp | 4 | ||||
-rw-r--r-- | src/init.cpp | 6 | ||||
-rw-r--r-- | src/nickserv.cpp | 8 | ||||
-rw-r--r-- | src/regchannel.cpp | 2 | ||||
-rw-r--r-- | src/socketengines/socketengine_eventfd.cpp | 7 | ||||
-rw-r--r-- | src/threadengines/threadengine_pthread.cpp | 9 | ||||
-rw-r--r-- | src/threadengines/threadengine_win32.cpp | 9 |
8 files changed, 46 insertions, 10 deletions
diff --git a/src/botserv.cpp b/src/botserv.cpp index c96ccb536..23482f76c 100644 --- a/src/botserv.cpp +++ b/src/botserv.cpp @@ -359,10 +359,15 @@ void botchanmsgs(User *u, ChannelInfo *ci, const Anope::string &buf) BotInfo *findbot(const Anope::string &nick) { + BotInfo *bi; if (isdigit(nick[0]) && ircd->ts6) - return BotListByUID.find(nick); - - return BotListByNick.find(nick); + bi = BotListByUID.find(nick); + else + bi = BotListByNick.find(nick); + + FOREACH_MOD(I_OnFindBot, OnFindBot(nick)); + + return bi; } /*************************************************************************/ diff --git a/src/chanserv.cpp b/src/chanserv.cpp index b66a36dbe..ef203c064 100644 --- a/src/chanserv.cpp +++ b/src/chanserv.cpp @@ -471,10 +471,12 @@ void cs_remove_nick(NickCore *nc) ChannelInfo *cs_findchan(const Anope::string &chan) { - registered_channel_map::const_iterator it = RegisteredChannelList.find(chan); + FOREACH_MOD(I_OnFindChan, OnFindChan(chan)); + registered_channel_map::const_iterator it = RegisteredChannelList.find(chan); if (it != RegisteredChannelList.end()) return it->second; + return NULL; } diff --git a/src/init.cpp b/src/init.cpp index c12f600fc..fc53d6a2b 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -375,13 +375,13 @@ void Init(int ac, char **av) /* Add Encryption Modules */ ModuleManager::LoadModuleList(Config->EncModuleList); - /* Add Database Modules */ - ModuleManager::LoadModuleList(Config->DBModuleList); - /* Load the socket engine */ if (ModuleManager::LoadModule(Config->SocketEngine, NULL) || !SocketEngine) throw FatalException("Unable to load socket engine " + Config->SocketEngine); + /* Add Database Modules */ + ModuleManager::LoadModuleList(Config->DBModuleList); + try { DNSEngine = new DNSManager(); diff --git a/src/nickserv.cpp b/src/nickserv.cpp index 65ffc02d1..f841ced10 100644 --- a/src/nickserv.cpp +++ b/src/nickserv.cpp @@ -319,10 +319,12 @@ NickRequest *findrequestnick(const Anope::string &nick) NickAlias *findnick(const Anope::string &nick) { - nickalias_map::const_iterator it = NickAliasList.find(nick); + FOREACH_MOD(I_OnFindNick, OnFindNick(nick)); + nickalias_map::const_iterator it = NickAliasList.find(nick); if (it != NickAliasList.end()) return it->second; + return NULL; } @@ -330,10 +332,12 @@ NickAlias *findnick(const Anope::string &nick) NickCore *findcore(const Anope::string &nick) { - nickcore_map::const_iterator it = NickCoreList.find(nick); + FOREACH_MOD(I_OnFindCore, OnFindCore(nick)); + nickcore_map::const_iterator it = NickCoreList.find(nick); if (it != NickCoreList.end()) return it->second; + return NULL; } diff --git a/src/regchannel.cpp b/src/regchannel.cpp index 4ab4062aa..b240b8554 100644 --- a/src/regchannel.cpp +++ b/src/regchannel.cpp @@ -494,6 +494,8 @@ void ChannelInfo::ClearBadWords() */ void ChannelInfo::LoadMLock() { + this->ClearMLock(); + std::vector<Anope::string> modenames_on, modenames_off; // Force +r diff --git a/src/socketengines/socketengine_eventfd.cpp b/src/socketengines/socketengine_eventfd.cpp index 4e4016326..9e9ec677b 100644 --- a/src/socketengines/socketengine_eventfd.cpp +++ b/src/socketengines/socketengine_eventfd.cpp @@ -53,7 +53,12 @@ bool Pipe::Read(const Anope::string &) void Pipe::Notify() { - this->Write("*"); + /* Note we send this immediatly. If use use Socket::Write and if this functions is called + * from a thread, only epoll is able to pick up the change to this sockets want flags immediately + * Other engines time out then pick up and write the change then read it back, which + * is too slow for most things. + */ + this->IO->Send(this, ""); } void Pipe::OnNotify() diff --git a/src/threadengines/threadengine_pthread.cpp b/src/threadengines/threadengine_pthread.cpp index 65d1533f3..acdccfeb5 100644 --- a/src/threadengines/threadengine_pthread.cpp +++ b/src/threadengines/threadengine_pthread.cpp @@ -79,6 +79,15 @@ void Mutex::Unlock() pthread_mutex_unlock(&mutex); } +/** Attempt to lock the mutex, will return true on success and false on fail + * Does not block + * @return true or false + */ +bool Mutex::TryLock() +{ + return pthread_mutex_trylock(&mutex) == 0; +} + /** Constructor */ Condition::Condition() : Mutex() diff --git a/src/threadengines/threadengine_win32.cpp b/src/threadengines/threadengine_win32.cpp index b270a895d..e6ad725bf 100644 --- a/src/threadengines/threadengine_win32.cpp +++ b/src/threadengines/threadengine_win32.cpp @@ -73,6 +73,15 @@ void Mutex::Unlock() LeaveCriticalSection(&mutex); } +/** Attempt to lock the mutex, will return true on success and false on fail + * Does not block + * @return true or false + */ +bool Mutex::TryLock() +{ + return TryEnterCriticalSection(&mutex); +} + /** Constructor */ Condition::Condition() : Mutex() |