fd_set readfds;
FD_ZERO(&readfds);
+ FD_SET(sockfd, &readfds);
#ifdef WIN32
#endif
struct timeval tv;
- tv.tv_sec = 20; // Allow 5s for a connect
+ tv.tv_sec = 10; // Allow 10s for a connect
tv.tv_usec = 0;
int selectResult = select(maxfd + 1, &readfds, &writefds, NULL, &tv);
return false;
}
- if ((selectResult == 1) || FD_ISSET(sockfd, &writefds))
+ logger->trace(TAG, "waitForConnect(): selectResult = {}", selectResult);
+
+ if ((selectResult == 1) && FD_ISSET(sockfd, &writefds))
{
logger->info(TAG, "Connected");
connected = true;
return true;
}
+ else if ((selectResult == 2) && FD_ISSET(sockfd, &readfds) && FD_ISSET(sockfd, &writefds))
+ {
+ CLOSESOCKET(sockfd);
+ sockfd = -1;
+ logger->crit(TAG, "Detected connection failed");
+ return false;
+ }
else
{
CLOSESOCKET(sockfd);
setOneLiner(tr("Connection failed"));
draw();
boxstack->update(this);
- if (threadReqQuit) return false;
- MILLISLEEP(3000); // FIXME wait on cond?
+ {
+ std::unique_lock<std::mutex> ul(threadMutex);
+ if (threadReqQuit) return false;
+ threadCond.wait_for(ul, std::chrono::milliseconds(3000), [this]{ return threadReqQuit; });
+ }
return false;
}
draw();
boxstack->update(this);
- if (threadReqQuit) return false;
- MILLISLEEP(3000); // FIXME wait on cond?
+
+ {
+ std::unique_lock<std::mutex> ul(threadMutex);
+ if (threadReqQuit) return false;
+ threadCond.wait_for(ul, std::chrono::milliseconds(3000), [this]{ return threadReqQuit; });
+ }
+
return false;
}
logger->debug(TAG, "VDR login ok");
- Config::getInstance()->set("subtitles", "default", subtitles);
+ Config::getInstance()->set("subtitles", "default", subtitles); // FIXME move this directly into vdr.cc ?
Wol::getInstance()->setWakeUpIP(vdrServer->ip.c_str());
logger->info(TAG, "Send VDR connected message");