X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;ds=sidebyside;f=win%2Finspircd_namedpipe.cpp;h=95c0ae5783fc204a41b234d4ad9b6f174906186a;hb=6d03943426dcce76ba66567a9b18425a5ebb4c0c;hp=d51172c05cd913da5610178a85e8debbe8048341;hpb=1ee5092d7528488b2e2160a57c5dcd433ac48d4d;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/win/inspircd_namedpipe.cpp b/win/inspircd_namedpipe.cpp index d51172c05..95c0ae578 100644 --- a/win/inspircd_namedpipe.cpp +++ b/win/inspircd_namedpipe.cpp @@ -6,13 +6,15 @@ #include -IPCThread::IPCThread(InspIRCd* Instance) : Thread(), ServerInstance(Instance) +IPCThread::IPCThread() { + if (!initwmi()) + ServerInstance->Logs->Log("IPC", DEBUG, "Could not initialise WMI. CPU percantage reports will not be available."); } IPCThread::~IPCThread() { - + donewmi(); } void IPCThread::Run() @@ -22,19 +24,19 @@ void IPCThread::Run() while (GetExitFlag() == false) { Pipe = CreateNamedPipe (Pipename, - PIPE_ACCESS_DUPLEX, // read/write access - PIPE_TYPE_MESSAGE | // message type pipe - PIPE_READMODE_MESSAGE | // message-read mode - PIPE_WAIT, // blocking mode - PIPE_UNLIMITED_INSTANCES, // max. instances - MAXBUF, // output buffer size - MAXBUF, // input buffer size - 1000, // client time-out - NULL); // no security attribute + PIPE_ACCESS_DUPLEX, // read/write access + PIPE_TYPE_MESSAGE | // message type pipe + PIPE_READMODE_MESSAGE | // message-read mode + PIPE_WAIT, // blocking mode + PIPE_UNLIMITED_INSTANCES, // max. instances + MAXBUF, // output buffer size + MAXBUF, // input buffer size + 1000, // client time-out + NULL); // no security attribute if (Pipe == INVALID_HANDLE_VALUE) { - SleepEx(500, true); + SleepEx(10, true); continue; } @@ -83,6 +85,8 @@ void IPCThread::Run() stat << "kbitspersectotal " << kbitpersec_total << std::endl; stat << "kbitspersecout " << kbitpersec_out << std::endl; stat << "kbitspersecin " << kbitpersec_in << std::endl; + stat << "uptime " << ServerInstance->Time() - ServerInstance->startup_time << std::endl; + stat << "cpu " << getcpu() << std::endl; if (HaveMemoryStats) { stat << "workingset " << MemCounters.WorkingSetSize << std::endl; @@ -123,11 +127,11 @@ void IPCThread::SetResult(int newresult) } -IPC::IPC(InspIRCd* Srv) : ServerInstance(Srv) +IPC::IPC() { /* The IPC pipe is threaded */ thread = new IPCThread(Srv); - Srv->Threads->Create(thread); + Srv->Threads->Start(thread); } void IPC::Check() @@ -157,6 +161,12 @@ void IPC::Check() thread->ClearStatus(); ServerInstance->Restart("Restarting due to command from GUI"); break; + case '4': + /* Toggle debug */ + thread->SetResult(0); + thread->ClearStatus(); + ServerInstance->Config->forcedebug = !ServerInstance->Config->forcedebug; + break; } } @@ -164,4 +174,4 @@ IPC::~IPC() { thread->SetExitFlag(); delete thread; -} \ No newline at end of file +}