BOOL FileTransferSocket::shutdown() { stopHeartbeat(); //_stopServerPingTimer(); imcore::IMLibCoreShutdown(m_socketHandle); return TRUE; }
QString Condition4Timer::updataConditionList() { QMultiHash<QString, QString> tmpMHTim2Job; { QMutexLocker locker(&m_Mutex4Job); for (int iJobIndex = 0;iJobIndex < m_list4Job.size();iJobIndex++) { QString strCurJob = m_list4Job[iJobIndex]; QStringList strlitTime = getConditionTime(strCurJob); for (int i = 0;i < strlitTime.size();i++) { tmpMHTim2Job.insert(strlitTime[0],strCurJob); } } } stopHeartbeat(); { QMutexLocker lLocker(&m_Mutex4Tim2Job); m_hashTim2Job.clear(); m_hashTim2Job = tmpMHTim2Job; } startHeartbeat(m_ibeatTime); return "Successful"; }
void mal_exit(void){ str err; /* * Before continuing we should make sure that all clients * (except the console) have left the scene. */ MCstopClients(0); #if 0 { int reruns=0, go_on; do{ if ( (go_on = MCactiveClients()) ) MT_sleep_ms(1000); mnstr_printf(mal_clients->fdout,"#MALexit: %d clients still active\n", go_on); } while (++reruns < SERVERSHUTDOWNDELAY && go_on > 1); } #endif stopHeartbeat(); #ifdef HAVE_JSONSTORE stopHttpdaemon(); #endif stopMALdataflow(); stopProfiling(); RECYCLEdrop(mal_clients); /* remove any left over intermediates */ unloadLibraries(); #if 0 /* skip this to solve random crashes, needs work */ freeModuleList(mal_clients->nspace); finishNamespace(); if( mal_clients->prompt) GDKfree(mal_clients->prompt); if( mal_clients->errbuf) GDKfree(mal_clients->errbuf); if( mal_clients->bak) GDKfree(mal_clients->bak); if( mal_clients->fdin){ /* missing protection against closing stdin stream */ (void) mnstr_close(mal_clients->fdin->s); (void) bstream_destroy(mal_clients->fdin); } if( mal_clients->fdout && mal_clients->fdout != GDKstdout) { (void) mnstr_close(mal_clients->fdout); (void) mnstr_destroy(mal_clients->fdout); } #endif /* deregister everything that was registered, ignore errors */ if ((err = msab_wildRetreat()) != NULL) { fprintf(stderr, "!%s", err); free(err); } /* the server will now be shut down */ if ((err = msab_registerStop()) != NULL) { fprintf(stderr, "!%s", err); free(err); } GDKexit(0); /* properly end GDK */ }
QString Condition4Timer::startHeartbeat( int ibeatTime ) { if (m_Timer4Heartbeat) stopHeartbeat(); m_Timer4Heartbeat = new QTimer(this); m_Timer4Heartbeat->setInterval(ibeatTime); connect(m_Timer4Heartbeat,SIGNAL(timeout()),this,SLOT(slotHandleHeartbeat()),Qt::QueuedConnection); m_Timer4Heartbeat->start(); return "Successful"; }
void Condition4Timer::slotHandleHeartbeat() { QDateTime cTime = QDateTime::currentDateTime(); QString hms; if (DAY == m_ConditionStep) { hms = cTime.toString("hh:mm:ss"); if (m_updataCondition4Day == hms) { stopHeartbeat(); updataConditionList(); } } if (HOUR == m_ConditionStep) { hms = cTime.toString("mm:ss"); if (m_updataCondition4Hour == hms) { stopHeartbeat(); updataConditionList(); } } { QMutexLocker lLocker(&m_Mutex4Tim2Job); //if (m_hashTim2Job.contains(hms)) //{ QMultiHash<QString, QString>::iterator iter = m_hashTim2Job.find(hms); while (iter != m_hashTim2Job.end() && iter.key() == hms) { QString needExecJob = iter.value(); emit signalExecJobOnCondition(needExecJob); ++iter; } //} } }
void WAKEUP::timerISR() { // Runs every heartbeat unsigned int runNowPtr = MAXPENDING; // Pointer to top end of _pending to use as temporary scratchpad for (int i = 0; i < _numSleepers; i++) { // If countdown has finished then put on pending queue and shuffle bunks (if needed) if ((_bunks[i].timeToWake -= _heartbeat) <= 0) { // Put in pending queue, either to wake in a few moments or from main program using runAnyPending // If runAnyPending not run fast enough then bottom-up and top-down queues may clash, so check if (_bunks[i].treatAsISR == TREAT_AS_ISR) { // Wake later in this function if (--runNowPtr <= _numPending) runNowPtr++; _pending[runNowPtr].callback = _bunks[i].callback; _pending[runNowPtr].context = _bunks[i].context; } else { // Wake in response to runAnyPending _pending[_numPending].callback = _bunks[i].callback; _pending[_numPending].context = _bunks[i].context; if (++_numPending >= runNowPtr) _numPending--; } // If others left after one-shot sleeper removed, take sleeper in topmost bunk and move to the newly-vacant bunk if (_bunks[i].sleepDuration > 0) { // Positive number means one-shot _numSleepers--; if (_numSleepers > 0) { // Move topmost sleeper into this bunk (v rarely might be the same one, but safe so ignore) _bunks[i].callback = _bunks[_numSleepers].callback; _bunks[i].treatAsISR = _bunks[_numSleepers].treatAsISR; _bunks[i].sleepDuration = _bunks[_numSleepers].sleepDuration; _bunks[i].timeToWake = _bunks[_numSleepers].timeToWake; _bunks[i].context = _bunks[_numSleepers].context; i--; // Decrement counter to ensure this sleeper isn't missed } } else _bunks[i].timeToWake -=_bunks[i].sleepDuration; // Repeating sleeper, just reset countdown } } // Start the heartbeat if sleepers left if (_numSleepers == 0) stopHeartbeat(); startHeartbeat(); // Run the TREAT_AS_ISR sleepers that were woken - be quick (and block runAnyPending() from being run) _inISR = true; for (int i = runNowPtr; i < MAXPENDING; i++) _pending[i].callback(_pending[i].context); _inISR = false; }
void FileTransferSocket::stopfileTransLink() { shutdown(); stopHeartbeat(); }
void FileTransferSocket::onClose(int error) { APP_LOG(LOG_INFO, _T("FileTransferSocket::onClose error code:%d"), error); stopHeartbeat(); }
void FileTransferSocket::onClose() { stopHeartbeat(); }
Condition4Timer::~Condition4Timer(void) { stopHeartbeat(); }