forked from qt-creator/qt-creator
zeroconf: improve startup of mdnssd
give enough startup time, while still quickly bailing out when quitting Change-Id: I628621099e9ead4defc4613615ccb5e8303ff2df Reviewed-by: Christian Kandeler <christian.kandeler@nokia.com>
This commit is contained in:
@@ -35,7 +35,9 @@
|
|||||||
|
|
||||||
#include "dnssd_ipc.h"
|
#include "dnssd_ipc.h"
|
||||||
|
|
||||||
namespace ZeroConf { namespace embeddedLib {
|
namespace ZeroConf {
|
||||||
|
extern int gQuickStop;
|
||||||
|
namespace embeddedLib {
|
||||||
#include "../dns_sd_funct.h"
|
#include "../dns_sd_funct.h"
|
||||||
static int gDaemonErr = kDNSServiceErr_NoError;
|
static int gDaemonErr = kDNSServiceErr_NoError;
|
||||||
}}
|
}}
|
||||||
@@ -233,7 +235,7 @@ static int read_all(dnssd_sock_t sd, char *buf, int len)
|
|||||||
int nVal=select(sd+1, &readFds, &writeFds, &exceptFds, &timeout);
|
int nVal=select(sd+1, &readFds, &writeFds, &exceptFds, &timeout);
|
||||||
if (nVal < 1 || !FD_ISSET(sd, &readFds)) {
|
if (nVal < 1 || !FD_ISSET(sd, &readFds)) {
|
||||||
++nErr;
|
++nErr;
|
||||||
if (nErr < 6) // wait max 6s without reading
|
if (nErr < 100 && ! ZeroConf::gQuickStop) // wait max 100s without reading
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
num_read = recv(sd, buf, len, 0);
|
num_read = recv(sd, buf, len, 0);
|
||||||
|
@@ -197,6 +197,8 @@ void ZeroConfLib::setDefaultLib(LibUsage usage, const QString &avahiLibName,
|
|||||||
|
|
||||||
namespace ZeroConf {
|
namespace ZeroConf {
|
||||||
|
|
||||||
|
int gQuickStop = 0;
|
||||||
|
|
||||||
// ----------------- ErrorMessage impl -----------------
|
// ----------------- ErrorMessage impl -----------------
|
||||||
/*!
|
/*!
|
||||||
\class ZeroConf::ErrorMessage
|
\class ZeroConf::ErrorMessage
|
||||||
@@ -1597,7 +1599,9 @@ MainConnection::MainConnection():
|
|||||||
|
|
||||||
MainConnection::~MainConnection()
|
MainConnection::~MainConnection()
|
||||||
{
|
{
|
||||||
|
gQuickStop = 1;
|
||||||
stop(true);
|
stop(true);
|
||||||
|
gQuickStop = 0;
|
||||||
delete m_thread;
|
delete m_thread;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user