From 540fee57bf71abccaba38c0297b80f8001780c1d Mon Sep 17 00:00:00 2001 From: brain Date: Sun, 10 Dec 2006 22:17:51 +0000 Subject: Add InspIRCd::UseInterface and InspIRCd::DoneWithInterface, and also InspIRCd::GetInterfaceUseCount(). These can be used for one module to lock other modules in memory that it depends on, this way they can enforce an unload order so that you cant (for example) unload m_ssl_gnutls.so whilst m_spanningtree.so is using it for ssl server to server sessions (in this case, youd have to unload spanningtree first, THEN ssl_gnutls, to satisfy the dependencies and unload orders) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5924 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/inspircd.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/inspircd.cpp') diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 12134f3f6..e7801f1d5 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -505,6 +505,17 @@ bool InspIRCd::UnloadModule(const char* filename) snprintf(MODERR,MAXBUF,"Module not unloadable (marked static)"); return false; } + std::pair intercount = GetInterfaceInstanceCount(modules[j]); + if (intercount.first > 0) + { + this->Log(DEFAULT,"Failed to unload module %s, being used by %d other(s) via interface '%s'",filename, intercount.first, intercount.second.c_str()); + snprintf(MODERR,MAXBUF,"Module not unloadable (Still in use by %d other module%s which %s using its interface '%s') -- unload dependent modules first!", + intercount.first, + intercount.first > 1 ? "s" : "", + intercount.first > 1 ? "are" : "is", + intercount.second.c_str()); + return false; + } /* Give the module a chance to tidy out all its metadata */ for (chan_hash::iterator c = this->chanlist.begin(); c != this->chanlist.end(); c++) { -- cgit v1.3.1-10-gc9f91