summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-03-23 20:42:17 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-03-23 20:42:17 +0000
commite7150d29f4897d595c9ee2218e190d6cf42f191b (patch)
treefd63b14d0b940b1c14d2d6989f589ec7dc249222
parent47a902e1f647fc017560b9a85eaddc64dc29aad8 (diff)
ConfigReaderThread updates: add done flag, remove main-thread-only mutex
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11256 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--include/inspircd.h7
-rw-r--r--include/threadengine.h3
-rw-r--r--src/configreader.cpp1
-rw-r--r--src/inspircd.cpp4
-rw-r--r--src/server.cpp2
5 files changed, 7 insertions, 10 deletions
diff --git a/include/inspircd.h b/include/inspircd.h
index f32a67644..24b7bc4d1 100644
--- a/include/inspircd.h
+++ b/include/inspircd.h
@@ -290,9 +290,11 @@ class CoreExport ConfigReaderThread : public Thread
{
InspIRCd* ServerInstance;
bool do_bail;
+ bool done;
std::string TheUserUID;
public:
- ConfigReaderThread(InspIRCd* Instance, bool bail, const std::string &useruid) : Thread(), ServerInstance(Instance), do_bail(bail), TheUserUID(useruid)
+ ConfigReaderThread(InspIRCd* Instance, bool bail, const std::string &useruid)
+ : Thread(), ServerInstance(Instance), do_bail(bail), done(false), TheUserUID(useruid)
{
}
@@ -301,6 +303,7 @@ class CoreExport ConfigReaderThread : public Thread
}
void Run();
+ bool IsDone() { return done; }
};
/** The main class of the irc server.
@@ -397,8 +400,6 @@ class CoreExport InspIRCd : public classbase
*/
std::map<BufferedSocket*,BufferedSocket*> SocketCull;
- Mutex RehashFinishMutex;
-
/** Globally accessible fake user record. This is used to force mode changes etc across s2s, etc.. bit ugly, but.. better than how this was done in 1.1
* Reason for it:
* kludge alert!
diff --git a/include/threadengine.h b/include/threadengine.h
index d7eaaef69..e1400eb95 100644
--- a/include/threadengine.h
+++ b/include/threadengine.h
@@ -30,8 +30,7 @@ class CoreExport Thread : public Extensible
/** Set to true when the thread is to exit
*/
bool ExitFlag;
-// TODO protected:
- public:
+ protected:
/** Get thread's current exit status.
* (are we being asked to exit?)
*/
diff --git a/src/configreader.cpp b/src/configreader.cpp
index 6444ee211..d8f733929 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -2372,4 +2372,5 @@ bool DoneELine(ServerConfig* conf, const char* tag)
void ConfigReaderThread::Run()
{
ServerInstance->Config->Read(do_bail, TheUserUID);
+ done = true;
}
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 7c82b706b..ab67449a2 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -762,8 +762,7 @@ int InspIRCd::Run()
#endif
/* Check if there is a config thread which has finished executing but has not yet been freed */
- RehashFinishMutex.Lock();
- if (this->ConfigThread && this->ConfigThread->GetExitFlag())
+ if (this->ConfigThread && this->ConfigThread->IsDone())
{
/* Rehash has completed */
@@ -798,7 +797,6 @@ int InspIRCd::Run()
delete ConfigThread;
ConfigThread = NULL;
}
- RehashFinishMutex.Unlock();
/* time() seems to be a pretty expensive syscall, so avoid calling it too much.
* Once per loop iteration is pleanty.
diff --git a/src/server.cpp b/src/server.cpp
index 46c17d14a..c7ebc187e 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -48,7 +48,6 @@ void InspIRCd::Exit(int status)
void RehashHandler::Call(const std::string &reason)
{
- Server->RehashFinishMutex.Lock();
Server->SNO->WriteToSnoMask('A', "Rehashing config file %s %s",ServerConfig::CleanFilename(Server->ConfigFileName), reason.c_str());
Server->RehashUsersAndChans();
FOREACH_MOD_I(Server, I_OnGarbageCollect, OnGarbageCollect());
@@ -60,7 +59,6 @@ void RehashHandler::Call(const std::string &reason)
Server->ConfigThread = new ConfigReaderThread(Server, false, "");
Server->Threads->Start(Server->ConfigThread);
}
- Server->RehashFinishMutex.Unlock();
}
void InspIRCd::RehashServer()