// Daemon is ready to work.
sd_notify(0, "READY=1");
-
+ m_starting = true;
m_working = true;
while(m_working) {
fd_set readSet = m_readSet;
m_timeoutQueue.push(tm);
}
}
-
- if (m_timeoutQueue.empty()) {
- LogDebug("No usaable timeout found.");
- ptrTimeout = NULL; // select will wait without timeout
- } else {
- time_t currentTime = time(NULL);
- auto &pqTimeout = m_timeoutQueue.top();
-
- // 0 means that select won't block and socket will be closed ;-)
- ptrTimeout->tv_sec =
- currentTime < pqTimeout.time ? pqTimeout.time - currentTime : 0;
+ if (m_starting) {
+ ptrTimeout->tv_sec = SOCKET_TIMEOUT;
ptrTimeout->tv_usec = 0;
-// LogDebug("Set up timeout: " << (int)ptrTimeout->tv_sec
-// << " seconds. Socket: " << pqTimeout.sock);
+ m_starting = false;
+ } else {
+ if (m_timeoutQueue.empty()) {
+ LogDebug("No useable timeout found.");
+ ptrTimeout->tv_sec = 0;
+ ptrTimeout->tv_usec = 0;
+ MainLoopStop();
+ } else {
+ time_t currentTime = time(NULL);
+ auto &pqTimeout = m_timeoutQueue.top();
+
+ // 0 means that select won't block and socket will be closed ;-)
+ ptrTimeout->tv_sec =
+ currentTime < pqTimeout.time ? pqTimeout.time - currentTime : 0;
+ ptrTimeout->tv_usec = 0;
+// LogDebug("Set up timeout: " << (int)ptrTimeout->tv_sec
+// << " seconds. Socket: " << pqTimeout.sock);
+ }
}
-
int ret = select(m_maxDesc+1, &readSet, &writeSet, NULL, ptrTimeout);
if (0 == ret) { // timeout