]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - win/inspircd_namedpipe.cpp
Change debug message in Invitation::Find() to output expiration time as a string...
[user/henk/code/inspircd.git] / win / inspircd_namedpipe.cpp
index d51172c05cd913da5610178a85e8debbe8048341..632c2cca0084ee836f79e7ea2ae62bd3d2a65cfe 100644 (file)
@@ -1,3 +1,22 @@
+/*
+ * InspIRCd -- Internet Relay Chat Daemon
+ *
+ *   Copyright (C) 2008 Craig Edwards <craigedwards@brainbox.cc>
+ *
+ * This file is part of InspIRCd.  InspIRCd is free software: you can
+ * redistribute it and/or modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+\r
 #include "inspircd.h"\r
 #include "threadengine.h"\r
 #include "inspircd_namedpipe.h"\r
 #include <psapi.h>\r
 \r
 \r
-IPCThread::IPCThread(InspIRCd* Instance) : Thread(), ServerInstance(Instance)\r
+IPCThread::IPCThread()\r
 {\r
+       if (!initwmi())\r
+               ServerInstance->Logs->Log("IPC", DEBUG, "Could not initialise WMI. CPU percantage reports will not be available.");\r
 }\r
 \r
 IPCThread::~IPCThread()\r
 {\r
-\r
+       donewmi();\r
 }\r
 \r
 void IPCThread::Run()\r
@@ -22,19 +43,19 @@ void IPCThread::Run()
        while (GetExitFlag() == false)\r
        {\r
                Pipe = CreateNamedPipe (Pipename,\r
-                                          PIPE_ACCESS_DUPLEX, // read/write access\r
-                                          PIPE_TYPE_MESSAGE | // message type pipe\r
-                                          PIPE_READMODE_MESSAGE | // message-read mode\r
-                                          PIPE_WAIT, // blocking mode\r
-                                          PIPE_UNLIMITED_INSTANCES, // max. instances\r
-                                          MAXBUF, // output buffer size\r
-                                          MAXBUF, // input buffer size\r
-                                          1000, // client time-out\r
-                                          NULL); // no security attribute\r
+                                       PIPE_ACCESS_DUPLEX, // read/write access\r
+                                       PIPE_TYPE_MESSAGE | // message type pipe\r
+                                       PIPE_READMODE_MESSAGE | // message-read mode\r
+                                       PIPE_WAIT, // blocking mode\r
+                                       PIPE_UNLIMITED_INSTANCES, // max. instances\r
+                                       MAXBUF, // output buffer size\r
+                                       MAXBUF, // input buffer size\r
+                                       1000, // client time-out\r
+                                       NULL); // no security attribute\r
 \r
                if (Pipe == INVALID_HANDLE_VALUE)\r
                {\r
-                       SleepEx(500, true);\r
+                       SleepEx(10, true);\r
                        continue;\r
                }\r
 \r
@@ -83,6 +104,8 @@ void IPCThread::Run()
                        stat << "kbitspersectotal " << kbitpersec_total << std::endl;\r
                        stat << "kbitspersecout " << kbitpersec_out << std::endl;\r
                        stat << "kbitspersecin " << kbitpersec_in << std::endl;\r
+                       stat << "uptime " << ServerInstance->Time() - ServerInstance->startup_time << std::endl;\r
+                       stat << "cpu " << getcpu() << std::endl;\r
                        if (HaveMemoryStats)\r
                        {\r
                                stat << "workingset " << MemCounters.WorkingSetSize << std::endl;\r
@@ -123,11 +146,11 @@ void IPCThread::SetResult(int newresult)
 }\r
 \r
 \r
-IPC::IPC(InspIRCd* Srv) : ServerInstance(Srv)\r
+IPC::IPC()\r
 {\r
        /* The IPC pipe is threaded */\r
-       thread = new IPCThread(Srv);\r
-       Srv->Threads->Create(thread);\r
+       thread = new IPCThread();\r
+       ServerInstance->Threads->Start(thread);\r
 }\r
 \r
 void IPC::Check()\r
@@ -157,6 +180,12 @@ void IPC::Check()
                        thread->ClearStatus();\r
                        ServerInstance->Restart("Restarting due to command from GUI");\r
                break;\r
+               case '4':\r
+                       /* Toggle debug */\r
+                       thread->SetResult(0);\r
+                       thread->ClearStatus();\r
+                       ServerInstance->Config->cmdline.forcedebug = !ServerInstance->Config->cmdline.forcedebug;\r
+               break;\r
        }\r
 }\r
 \r
@@ -164,4 +193,4 @@ IPC::~IPC()
 {\r
        thread->SetExitFlag();\r
        delete thread;\r
-}
\ No newline at end of file
+}\r