//--------------------------------------------------------------------------- void TCustomMsgServer::TerminateAll() { int c; longword Elapsed; bool Timeout; if (ClientsCount > 0) { for (c = 0; c < MaxWorkers; c++) { if (Workers[c] != 0) PMsgWorkerThread(Workers[c])->Terminate(); } // Wait for closing Elapsed = SysGetTick(); Timeout = false; while (!Timeout && (ClientsCount > 0)) { Timeout = DeltaTime(Elapsed) > WkTimeout; if (!Timeout) SysSleep(100); }; if (ClientsCount > 0) KillAll(); // one o more threads are hanged ClientsCount = 0; } }
// Perform shutdown int ScheddCronJobMgr::Shutdown( bool force ) { dprintf( D_FULLDEBUG, "ScheddCronJobMgr: Shutting down\n" ); m_shutting_down = false; return KillAll( force ); }
void TContainerHolder::RemoveLeftovers() { TError error; for (auto hy: Hierarchies) { std::vector<TCgroup> cgroups; error = hy->Cgroup(PORTO_ROOT_CGROUP).ChildsAll(cgroups); if (error) L_ERR() << "Cannot dump porto " << hy->Type << " cgroups : " << error << std::endl; for (auto cg = cgroups.rbegin(); cg != cgroups.rend(); cg++) { std::string name = cg->Name.substr(strlen(PORTO_ROOT_CGROUP) + 1); if (Containers.count(name)) continue; if (!cg->IsEmpty()) (void)cg->KillAll(9); (void)cg->Remove(); } } for (auto it: Containers) { auto container = it.second; if (container->Prop->Get<bool>(P_WEAK)) { auto holder_lock = ScopedLock(); L_ACT() << "Destroy weak container " << it.first << std::endl; Destroy(holder_lock, container); } } }
BOOL CTBVAutoLauncher::Run() { if (FALSE == ReadConfig()) { CGlobalClass::GetInstance()->GetLogWriter()->WriteLog(LOG_TYPE_ERROR, L"CTBVAutoLauncher - Falure to read configuration"); return FALSE; } CGlobalClass::GetInstance()->GetLogWriter()->WriteLog(LOG_TYPE_FYI, L"CTBVAutoLauncher - Start running TBV1 Launcher"); if (FALSE == StartLauncherProcess()) { CGlobalClass::GetInstance()->GetLogWriter()->WriteLog(LOG_TYPE_ERROR, L"CTBVAutoLauncher - Unable to start launcher process"); return FALSE; } m_hMainWindow = CLauncherEx::WaitForWindow(m_strBV1WindowClass, m_strBV1WindowTitle, m_dwLauncherTimeOut); if (NULL == m_hMainWindow) { CGlobalClass::GetInstance()->GetLogWriter()->WriteLog(LOG_TYPE_ERROR, L"CTBVAutoLauncher - Waiting for TBV1 Game Window Timeout"); KillAll(); return FALSE; } CMyUtils::KillWindowProcess(m_hMainWindow); CreateSourceAndLauncherPath(L"BaVuong2", L"ga2.exe"); ReleaseProcess(); CGlobalClass::GetInstance()->GetLogWriter()->WriteLog(LOG_TYPE_FYI, L"CTBVAutoLauncher - Start running TBV2 Launcher"); m_hMainWindow = StartLauncherWindow(m_strBV2WindowClass, m_strBV2WindowTitle); if (NULL == m_hMainWindow) { CGlobalClass::GetInstance()->GetLogWriter()->WriteLog(LOG_TYPE_ERROR, L"CTBVAutoLauncher - Unable to start launcher process"); return FALSE; } CGlobalClass::GetInstance()->GetLogWriter()->WriteLogFormat(LOG_TYPE_FYI, L"CTBVAutoLauncher - Begin sleeping within %u minute(s)", m_dwTimeOutInMinute); for (int i = 0; i < m_dwTimeOutInMinute; i++) { ::Sleep(1000*60); CGlobalClass::GetInstance()->GetLogWriter()->WriteLogFormat(LOG_TYPE_FYI, L"CTBVAutoLauncher - %d minute(s)", i + 1); } CGlobalClass::GetInstance()->GetLogWriter()->WriteLogFormat(LOG_TYPE_FYI, L"CTBVAutoLauncher - Finish sleeping within %u minute(s)", m_dwTimeOutInMinute); CMyUtils::KillWindowProcess(m_hMainWindow); //::SendMessage(m_hMainWindow, WM_CLOSE, 0, 0); return TRUE; }
// Kill & delete all running workers int ForkWork::DeleteAll( void ) { ForkWorker *worker; // Kill 'em all KillAll( true ); // Walk through the list workerList.Rewind( ); while ( workerList.Next( worker ) ) { workerList.DeleteCurrent( ); delete worker; } return 0; }
~LoopStructureGraph() { KillAll(); }
int Logger(LISTE *plcs) { int res=0,Comm_err=0,Read_Something=0; if (TEST) { ListePlc(plcs); //return(0); } int now=time(NULL); res=BuildSockets(plcs); while (!Terminated) { ELEMENT *elt=GetFirst(plcs); while (elt!=NULL) // PLCs { PLC *plc=elt->Data; /* Something to do ? */ if (plc->Next_Time>time(NULL)) { elt=GetNext(plcs,elt); continue; } /* Test Socket */ if (plc->socket<0) { if (BuildSocket(plc)<0) { Log(LOG_WARNING,"Socket unavailable for : %s\n",plc->PlcName); plc->Next_Time=now+WAIT_FOR_RECONNECT; elt=GetNext(plcs,elt); continue; } else Log(LOG_INFO,"Socket build for : %s\n",plc->PlcName); } now=time(NULL); Read_Something=0; Comm_err=1; //plc->Next_Time=now+0.95*MAX_SAMPLE/1000; plc->Next_Time=now+MAX_SAMPLE; Log(LOG_DEBUG,"Set plc->Next_Time in %d seconds (MAX_SAMPLE : %d)\n",plc->Next_Time-now,MAX_SAMPLE); /* Read Tags */ ELEMENT *elt2=GetFirst(&(plc->Tags)); while (elt2!=NULL) { TAG *tag=elt2->Data; if ((now-tag->Time_Value)>(1.5*tag->Time_Sample)) Log(LOG_WARNING,"Time Sample exceed on tag : %s (%s)\n",tag->TagName,plc->PlcName); if ((now-tag->Time_Value)>=tag->Time_Sample) { //Log(LOG_DEBUG,"Reading tag : %s (%s) (%d - %d > %d)\n",tag->TagName,plc->PlcName,now,tag->Time_Value,tag->Time_Sample); Read_Something=1; res=ReadTag(plc,tag); if (res==0) Comm_err=0; // At least one tag is Ok if (mb_errno==EPIPE) CloseSocket(plc->socket,plcs); } if ((tag->Time_Value+tag->Time_Sample)<(plc->Next_Time)) { plc->Next_Time=tag->Time_Value+tag->Time_Sample; Log(LOG_DEBUG,"plc->Next_Time in %d seconds*\n",plc->Next_Time-now); } elt2=GetNext(&(plc->Tags),elt2); } /* Read Packets */ elt2=GetFirst(&(plc->Packets)); while (elt2!=NULL) { PACKET *packet=elt2->Data; if ((now-packet->Time_Value)>(1.5*packet->Time_Sample)) Log(LOG_WARNING,"Time Sample exceed on packet : %s (%s)\n",packet->BaseAddress,plc->PlcName); if ((now-packet->Time_Value)>=packet->Time_Sample) { Read_Something=1; res=ReadPacket(plc,packet); if (res>=0) Comm_err=0; // At least one tag is Ok if (mb_errno==EPIPE) CloseSocket(plc->socket,plcs); } if ((packet->Time_Value+packet->Time_Sample)<(plc->Next_Time)) { plc->Next_Time=packet->Time_Value+packet->Time_Sample; Log(LOG_DEBUG,"plc->Next_Time in %d seconds\n",plc->Next_Time-now); } elt2=GetNext(&(plc->Packets),elt2); } /* Check Plc */ if (Comm_err && Read_Something) // All Tags & packets are in error { Log(LOG_WARNING,"All tags in error for : %s suspending for %d seconds\n",plc->PlcName,WAIT_FOR_RECONNECT); plc->Next_Time=now+WAIT_FOR_RECONNECT; } if (plc->Next_Time>0.8*(time(NULL)+MODBUS_SOCK_TIMEOUT)) { close(plc->socket); plc->socket=-1; Log(LOG_DEBUG,"Closing socket for plc : %s \n",plc->PlcName); } elt=GetNext(plcs,elt); } sleep(1); } Log(LOG_NOTICE,"Killing Connections\n"); KillAll(plcs); FreeAll(plcs); return(0); }
// Perform shutdown int StartdBenchJobMgr::Shutdown( bool force ) { dprintf( D_FULLDEBUG, "StartdBenchJobMgr: Shutting down\n" ); return KillAll( force ); }
void kickall_command(char*arg){KillAll(CLEAN,"0");};
/******************************************************************** ** This function will clear all lists associated with a session ** ********************************************************************/ void killall_command(char*arg){KillAll(CLEAN,"1");};
JThreadGroup::~JThreadGroup(void) { KillAll(); }