示例#1
0
void ProcessDNSMessages() {
	static boolean initialized;
	
	if ( !initialized ) {
		initialized = true;
		DNSServiceErrorType err = DNSServiceBrowse ( 
													&browseRef, 
													0,					/* flags */
													0,					/* interface */
													serviceName, 
													NULL,				/* domain */
													DNSServiceBrowseReplyCallback, 
													NULL				/* context */
													);  
		if ( err != kDNSServiceErr_NoError ) {
			printf( "DNSServiceBrowse error\n" );
			return;
		}		
	}
	
	// poll the socket for updates
	int	socket = DNSServiceRefSockFD( browseRef );
	if ( socket <= 0 ) {
		return;
	}
	fd_set	set;
	FD_ZERO( &set );
	FD_SET( socket, &set );
	
	struct timeval tv;
	memset( &tv, 0, sizeof( tv ) );
	if ( select( socket+1, &set, NULL, NULL, &tv ) > 0 ) {
		DNSServiceProcessResult( browseRef );
	}	
}
示例#2
0
void CZeroconfWIN::ProcessResults()
{
  CSingleLock lock(m_data_guard);
  DNSServiceErrorType err = DNSServiceProcessResult(m_service);
  if (err != kDNSServiceErr_NoError)
    CLog::Log(LOGERROR, "ZeroconfWIN: DNSServiceProcessResult returned (error = %ld)", (int) err);
}
示例#3
0
文件: ow_browse.c 项目: M-o-a-T/owfs
// Called in a thread
static void * OW_Browse_Bonjour(void * v)
{
	struct connection_in * in = v ;
	DNSServiceErrorType dnserr;

	DETACH_THREAD;
	MONITOR_RLOCK ;
	dnserr = DNSServiceBrowse(&in->master.browse.bonjour_browse, 0, 0, "_owserver._tcp", NULL, BrowseBack, NULL);

	if (dnserr != kDNSServiceErr_NoError) {
		LEVEL_CONNECT("DNSServiceBrowse error = %d", dnserr);
		MONITOR_RUNLOCK ;
		return VOID_RETURN ;
	}

	// Blocks, which is why this is in it's own thread
	while (DNSServiceProcessResult(in->master.browse.bonjour_browse) == kDNSServiceErr_NoError) {
		//printf("DNSServiceProcessResult ref %ld\n",(long int)rs->sref) ;
		continue;
	}
	DNSServiceRefDeallocate(in->master.browse.bonjour_browse);
	in->master.browse.bonjour_browse = 0 ;
	MONITOR_RUNLOCK ;
	return VOID_RETURN;
}
示例#4
0
void AutoDiscoveryServerImpl::update()
{
    int dns_sd_fd  = client    ? DNSServiceRefSockFD(client   ) : -1;
    int nfds = dns_sd_fd + 1;
    fd_set readfds;
    struct timeval tv;
    int result;
    
//     (dns_sd_fd2 > dns_sd_fd) nfds = dns_sd_fd2 + 1;

    // 1. Set up the fd_set as usual here.
    // This example client has no file descriptors of its own,
    // but a real application would call FD_SET to add them to the set here
    FD_ZERO(&readfds);

    // 2. Add the fd for our client(s) to the fd_set
    if (client   ) FD_SET(dns_sd_fd , &readfds);
    //if (client_pa) FD_SET(dns_sd_fd2, &readfds);

    // 3. Set up the timeout.
    tv.tv_sec  = 0;
    tv.tv_usec = 0;

    result = select(nfds, &readfds, (fd_set*)NULL, (fd_set*)NULL, &tv);
    if (result > 0)
    {
        DNSServiceErrorType err = kDNSServiceErr_NoError;
        if      (client    && FD_ISSET(dns_sd_fd , &readfds)) err = DNSServiceProcessResult(client   );
//        else if (client_pa && FD_ISSET(dns_sd_fd2, &readfds)) err = DNSServiceProcessResult(client_pa);
//        if (err) { fprintf(stderr, "DNSServiceProcessResult returned %d\n", err); stopNow = 1; }
    }
}
void *	wxServiceDiscoveryTaskBase::wxServiceDiscoveryServiceHelperThread::Entry()
{
		//	static wxCriticalSection section;
		//	wxCriticalSectionLocker section_locker( section );
		
		wxASSERT( ! wxThread::IsMain() );
		
		bool cancel_running = false;
		DNSServiceErrorType err = kDNSServiceErr_NoError; 
		
		do
		{
			err = DNSServiceProcessResult( m_ServiceRef );
			
			if ( err )
			{
				if ( err == kDNSServiceErr_Unknown )
				{
					wxLogDebug( wxT("Received an unknown bonjour error, but this was probably just a method of quitting our thread.") );
				}
				else
				{
					wxLogDebug( wxT("got error!  %d"),
								err );
				}
				cancel_running = true;
			}
			
		} while ( ! TestDestroy() && !cancel_running );
		
		return NULL;
}
示例#6
0
bool CZeroconfBrowserWIN::doResolveService(CZeroconfBrowser::ZeroconfService& fr_service, double f_timeout)
{
  DNSServiceErrorType err;
  DNSServiceRef sdRef = NULL;

  err = DNSServiceResolve(&sdRef, 0, kDNSServiceInterfaceIndexAny, fr_service.GetName(), fr_service.GetType(), fr_service.GetDomain(), ResolveCallback, &fr_service);

  if( err != kDNSServiceErr_NoError )
  {
    if (sdRef)
      DNSServiceRefDeallocate(sdRef);

    CLog::Log(LOGERROR, "ZeroconfBrowserWIN: DNSServiceResolve returned (error = %ld)", (int) err);
    return false;
  }

  err = DNSServiceProcessResult(sdRef);

  if (err != kDNSServiceErr_NoError)
      CLog::Log(LOGERROR, "ZeroconfBrowserWIN::doResolveService DNSServiceProcessResult returned (error = %ld)", (int) err);

  if (sdRef)
    DNSServiceRefDeallocate(sdRef);

  return true;
}
示例#7
0
 ConnectionError Client::recv( int timeout )
 {
   if( m_connection && m_connection->state() == StateConnected )
     return ClientBase::recv( timeout );
   else
   {
     if( !m_currentRef )
       return ConnNoError;
     
     struct timeval tv;
     
     fd_set fds;
     FD_ZERO( &fds );
     // the following causes a C4127 warning in VC++ Express 2008 and possibly other versions.
     // however, the reason for the warning can't be fixed in gloox.
     FD_SET( DNSServiceRefSockFD( m_currentRef ), &fds );
     
     tv.tv_sec = timeout / 1000000;
     tv.tv_usec = timeout % 1000000;
     
     if( select( FD_SETSIZE, &fds, 0, 0, timeout == -1 ? 0 : &tv ) > 0 )
     {
       if( FD_ISSET( DNSServiceRefSockFD( m_currentRef ), &fds ) != 0 )
         DNSServiceProcessResult( m_currentRef );
     }
     
     return ConnNoError;
   }
 }
示例#8
0
void ZeroconfBrowser::socketReadyRead()
{
	DNSServiceErrorType err = DNSServiceProcessResult(m_DnsServiceRef);
	if (err != kDNSServiceErr_NoError) {
		emit error(err);
	}
}
  void register_service(DNSServiceRef service) {
    // Run until break.
    int dns_sd_fd = DNSServiceRefSockFD(service);
    fd_set readfds;
    struct timeval tv;
    int result;

    while (should_run()) {
      FD_ZERO(&readfds);
      FD_SET(dns_sd_fd, &readfds);
      tv.tv_sec = LONG_TIME;
      tv.tv_usec = 0;
                      // highest fd in set + 1
      result = select(dns_sd_fd+1, &readfds, (fd_set*)NULL, (fd_set*)NULL, &tv);
      if (result > 0) {
        DNSServiceErrorType err = kDNSServiceErr_NoError;
        // Execute callback
        if (FD_ISSET(dns_sd_fd, &readfds)) err = DNSServiceProcessResult(service);

        if (err) {
          // An error occured. Halt.
          fprintf(stderr, "DNSServiceProcessResult returned %d\n", err);
          quit();
        }
      }	else if (errno != EINTR) {
        // Error.
        fprintf(stderr, "ZeroConf error (%d %s)\n", errno, strerror(errno));
        if (errno != EINTR) quit();
      }
    }
  }
示例#10
0
static void
_ptpip_enumerate (
	DNSServiceRef sdRef, DNSServiceFlags flags,
	uint32_t interfaceIndex, DNSServiceErrorType errorCode,
	const char *serviceName, const char *regtype, const char *replyDomain,
	void *context
) {
	struct mdnsinfo mdnsi;
	DNSServiceRef		sd;

	if (errorCode != kDNSServiceErr_NoError) {
		gp_log (GP_LOG_ERROR, "ptpip", "Error on _ptp._tcp query.");
		return;
	}
	gp_log (GP_LOG_DEBUG, "ptpip", "found %s, %s, %s", serviceName, regtype, replyDomain);
	mdnsi.list = context;
	mdnsi.name = serviceName;
	DNSServiceResolve (&sd,
		0,
		interfaceIndex,
		serviceName,
		regtype,
		replyDomain,
		_ptpip_resolved,
		&mdnsi
	);
	DNSServiceProcessResult (sd);
	DNSServiceRefDeallocate (sd);
}
示例#11
0
/* static */ void
_SocketCallBack(CFSocketRef s, CFSocketCallBackType type, CFDataRef address, const void* data, void* info) {

	DNSServiceErrorType err;
	__CFNetServiceBrowser* browser = info;

	(void)s;		// unused
	(void)type;		// unused
	(void)address;  // unused
	(void)data;		// unused

	CFRetain(browser);

	// Dispatch to process the result
	err = DNSServiceProcessResult(browser->_browse);

	// If there was an error, need to infor the client.
	if (err) {

		// Dispatch based upon search type.
		if (browser->_domainSearch)
			_DomainEnumReply(browser->_browse, 0, 0, err, NULL, info);
		else
			_BrowseReply(browser->_browse, 0, 0, err, NULL, NULL, NULL, info);
	}

	CFRelease(browser);
}
示例#12
0
bool MLNetServiceHub::pollService(DNSServiceRef dnsServiceRef, double timeOutInSeconds, DNSServiceErrorType &err)
{
	assert(dnsServiceRef);

	err = kDNSServiceErr_NoError;
	
  fd_set readfds;
	FD_ZERO(&readfds);
	
  int dns_sd_fd = DNSServiceRefSockFD(dnsServiceRef);
  int nfds = dns_sd_fd+1;
	FD_SET(dns_sd_fd, &readfds);
	
  struct timeval tv;
  tv.tv_sec = long(floor(timeOutInSeconds));
  tv.tv_usec = long(1000000*(timeOutInSeconds - tv.tv_sec));
	
	int result = select(nfds,&readfds,NULL,NULL,&tv);
	if(result>0 && FD_ISSET(dns_sd_fd, &readfds))
	{
		err = DNSServiceProcessResult(dnsServiceRef);
		return true;
	}
	
	return false;
}
示例#13
0
/*
 * CFRunloop callback that calls DNSServiceProcessResult() when
 * there's new data on the socket.
 */
static void
socket_callback(CFSocketRef s, CFSocketCallBackType callbackType, CFDataRef address, const void *data, void *context)
{
	struct cbinfo *info = context;
	DNSServiceErrorType err;

	if (callbackType == kCFSocketNoCallBack) {
		printf("socket_callback: kCFSocketNoCallBack?\n");
		return;
	}

	if ((err = DNSServiceProcessResult(info->sdref)) != kDNSServiceErr_NoError) {
		printf("DNSServiceProcessResult() returned an error! %d\n", err);
		if (err == kDNSServiceErr_BadReference) {
			printf("bad reference?: %p, %d, %p, %p %p\n", s, (int)callbackType, address, data, context);
			return;
		}
		if ((context == &nfsinfo) || (context == &mountdinfo)) {
			/* bail if there's a problem with the main browse connection */
			exit(1);
		}
		/* dump the troublesome service connection */
		CFRunLoopRemoveSource(CFRunLoopGetCurrent(), info->rls, kCFRunLoopDefaultMode);
		CFRelease(info->rls);
		CFSocketInvalidate(info->sockref);
		CFRelease(info->sockref);
		DNSServiceRefDeallocate(info->sdref);
		free(info);
	}
}
示例#14
0
LONG
CSecondPage::OnServiceEvent(WPARAM inWParam, LPARAM inLParam)
{
	if (WSAGETSELECTERROR(inLParam) && !(HIWORD(inLParam)))
    {
		dlog( kDebugLevelError, "OnServiceEvent: window error\n" );
    }
    else
    {
		SOCKET sock = (SOCKET) inWParam;

		// iterate thru list
		ServiceRefList::iterator begin = m_serviceRefList.begin();
		ServiceRefList::iterator end   = m_serviceRefList.end();

		while (begin != end)
		{
			DNSServiceRef ref = *begin++;

			check(ref != NULL);

			if ((SOCKET) DNSServiceRefSockFD(ref) == sock)
			{
				DNSServiceProcessResult(ref);
				break;
			}
		}
	}

	return ( 0 );
}
LRESULT CALLBACK wxServiceDiscoveryTaskBase::WndProc(HWND inWindow,
													 UINT inMsg,
													 WPARAM inWParam,
													 LPARAM inLParam ) 
{ 
    LRESULT result; 
    switch(inMsg) 
	{ 
        case DNSSD_EVENT: 
			// Process the DNS-SD event. All DNS-SD callbacks occur from 
			// within this function. 
			{
				void * ptr = GetProp( inWindow, PROPNAME );

				wxServiceDiscoveryTaskBase * self = reinterpret_cast<wxServiceDiscoveryTaskBase *>( ptr );

				if (DNSServiceProcessResult( self->m_rServiceRef ) != kDNSServiceErr_NoError) 
					result = -1; 
				else 
					result = 0; 
			}
			break; 

		case WM_NCDESTROY:

			RemoveProp( inWindow, PROPNAME );
			// fall through

        default: 
			result = DefWindowProc(inWindow, inMsg, inWParam, inLParam); 
			break; 
	} 
    return(result); 
} 
示例#16
0
boolean RegisterGameService() {
	DNSServiceErrorType	err = DNSServiceRegister( 
					   &serviceRef, 
					   kDNSServiceFlagsNoAutoRename,		// we want a conflict error
					   InterfaceIndexForName( "en0" ),		// pass 0 for all interfaces
					   "iPhone Doom Classic",
					   serviceName,
					   NULL,	// domain
					   NULL,	// host
					   htons( DOOM_PORT ),
					   0,		// txtLen
					   NULL,	// txtRecord
					   DNSServiceRegisterReplyCallback,
					   NULL		// context
					   );
	
	if ( err != kDNSServiceErr_NoError ) {
		printf( "DNSServiceRegister error\n" );
	} else {
		// block until we get a response, process it, and run the callback
		err = DNSServiceProcessResult( serviceRef );
		if ( err != kDNSServiceErr_NoError ) {
			printf( "DNSServiceProcessResult error\n" );
		}
	}
	return localServer;
}
示例#17
0
void QZeroConfPrivate::browserRead()
{
	DNSServiceErrorType err = DNSServiceProcessResult(browser);
	if (err != kDNSServiceErr_NoError) {
		cleanUp(browser);
		emit pub->error(QZeroConf::browserFailed);
	}
}
示例#18
0
static void HandleEvents(void)
{
    int dns_sd_fd  = client  ? DNSServiceRefSockFD(client ) : -1;
    int dns_sd_fd2 = client2 ? DNSServiceRefSockFD(client2) : -1;
    int nfds = dns_sd_fd + 1;
    fd_set readfds;
    struct timeval tv;
    int result;

    if (dns_sd_fd2 > dns_sd_fd) nfds = dns_sd_fd2 + 1;

    while (!stopNow)
    {
        // 1. Set up the fd_set as usual here.
        // This example client has no file descriptors of its own,
        // but a real application would call FD_SET to add them to the set here
        FD_ZERO(&readfds);

        // 2. Add the fd for our client(s) to the fd_set
        if (client ) FD_SET(dns_sd_fd , &readfds);
        if (client2) FD_SET(dns_sd_fd2, &readfds);

        // 3. Set up the timeout.
        tv.tv_sec  = timeOut;
        tv.tv_usec = 0;

        result = select(nfds, &readfds, (fd_set*)NULL, (fd_set*)NULL, &tv);
        if (result > 0)
        {
            DNSServiceErrorType err = kDNSServiceErr_NoError;
            if      (client  && FD_ISSET(dns_sd_fd , &readfds)) err = DNSServiceProcessResult(client );
            else if (client2 && FD_ISSET(dns_sd_fd2, &readfds)) err = DNSServiceProcessResult(client2);
            if (err) {
                fprintf(stderr, "DNSServiceProcessResult returned %d\n", err);
                stopNow = 1;
            }
        }
        else if (result == 0)
            myTimerCallBack();
        else
        {
            printf("select() returned %d errno %d %s\n", result, errno, strerror(errno));
            if (errno != EINTR) stopNow = 1;
        }
    }
}
示例#19
0
void QZeroConfPrivate::bsRead()
{
	DNSServiceErrorType err = DNSServiceProcessResult(dnssRef);
	if (err != kDNSServiceErr_NoError) {
		cleanUp(dnssRef);
		emit pub->error(QZeroConf::serviceRegistrationFailed);
	}
}
示例#20
0
文件: ow_zero.c 项目: M-o-a-T/owfs
static void Announce_Post_Register(DNSServiceRef sref, DNSServiceErrorType err)
{
	if (err == kDNSServiceErr_NoError) {
		DNSServiceProcessResult(sref);
	} else {
		LEVEL_CONNECT("Unsuccessful call to DNSServiceRegister err = %d", err);
	}
}
示例#21
0
void BonjourBrowser::bonjourSocketReadyRead ()
{
    DNSServiceErrorType err;
    err = DNSServiceProcessResult(d->dnssref);
    if (err != kDNSServiceErr_NoError) {
        setError(err);
    }
}
/**
 * \brief Main method for the 
 */
void	BonjourDiscovery::main() {
	debug(LOG_DEBUG, DEBUG_LOG, 0, "start thread");
	assert(sdRef != NULL);
	int	error;
	do {
		error = DNSServiceProcessResult(sdRef);
	} while (error == kDNSServiceErr_NoError);
	debug(LOG_DEBUG, DEBUG_LOG, 0, "end thread");
}
示例#23
0
////////////////////////////////////////////////////
// called by the Tcl event loop when there is data
// on the socket used by the DNS service reference
////////////////////////////////////////////////////
void bonjour_tcl_callback(
   ClientData clientData,
   int mask
) {
   DNSServiceRef sdRef = (DNSServiceRef)clientData;

   // process the incoming data
   DNSServiceProcessResult(sdRef);
}
示例#24
0
void KprZeroconfPlatformCallBack(FskThreadDataHandler handler, FskThreadDataSource source, void* context)
#endif
{
	DNSServiceRef serviceRef = context;
	DNSServiceErrorType error = kDNSServiceErr_NoError;
	error = DNSServiceProcessResult(serviceRef);
	if (error)
		FskDebugStr("!!! KprZeroconfPlatformCallBack error %d", error);
}
示例#25
0
static void
mdns_event_cb(evutil_socket_t fd, short flags, void *data) {

  DNSServiceErrorType err;

  err = DNSServiceProcessResult(mdns_sdref_main);

  if (err != kDNSServiceErr_NoError)
    DPRINTF(E_LOG, L_MDNS, "DNSServiceProcessResult error %d\n", err);
}
示例#26
0
    void handleEvents_( DNSServiceRef service, const int32_t timeout = -1 )
    {
        assert( service );
        if( !service )
            return;

        const int fd = DNSServiceRefSockFD( service );
        const int nfds = fd + 1;

        while( !handled_ )
        {
            fd_set fdSet;
            FD_ZERO( &fdSet );
            FD_SET( fd, &fdSet );

            struct timeval tv;
            tv.tv_sec = timeout / 1000;
            tv.tv_usec = (timeout % 1000) * 1000;

            const int result = ::select( nfds, &fdSet, 0, 0,
                                         timeout < 0 ? 0 : &tv );
            switch( result )
            {
              case 0: // timeout
                return;

              case -1: // error
                LBWARN << "Select error: " << strerror( errno ) << " ("
                          << errno << ")" << std::endl;
                if( errno != EINTR )
                {
                    withdraw();
                    handled_ = true;
                }
                break;

              default:
                if( FD_ISSET( fd, &fdSet ))
                {
                    const DNSServiceErrorType error =
                        DNSServiceProcessResult( service );

                    if( error != kDNSServiceErr_NoError )
                    {
                        LBWARN << "DNSServiceProcessResult error: " << error
                               << std::endl;
                        withdraw();
                        handled_ = true;
                    }
                }
                break;
            }
        }
        handled_ = false;
    }
示例#27
0
static void do_smb_resolve(struct mdns_smbsrv_result *browsesrv)
{
	DNSServiceRef mdns_conn_sdref = NULL;
	int mdnsfd;
	int fdsetsz;
	int ret;
	fd_set *fdset = NULL;
	struct timeval tv;
	DNSServiceErrorType err;

	TALLOC_CTX * ctx = talloc_tos();

	err = DNSServiceResolve(&mdns_conn_sdref, 0 /* flags */,
		browsesrv->ifIndex,
		browsesrv->serviceName, browsesrv->regType, browsesrv->domain,
		do_smb_resolve_reply, NULL);

	if (err != kDNSServiceErr_NoError) {
		return;
	}

	mdnsfd = DNSServiceRefSockFD(mdns_conn_sdref);
	for (;;)  {
		if (fdset != NULL) {
			TALLOC_FREE(fdset);
		}

		if (mdnsfd < 0 || mdnsfd >= FD_SETSIZE) {
			errno = EBADF;
			break;
		}

		fdsetsz = howmany(mdnsfd + 1, NFDBITS) * sizeof(fd_mask);
		fdset = TALLOC_ZERO(ctx, fdsetsz);
		FD_SET(mdnsfd, fdset);

		tv.tv_sec = 1;
		tv.tv_usec = 0;

		/* Wait until response received from mDNS daemon */
		ret = sys_select(mdnsfd + 1, fdset, NULL, NULL, &tv);
		if (ret <= 0 && errno != EINTR) {
			break;
		}

		if (FD_ISSET(mdnsfd, fdset)) {
			/* Invoke callback function */
			DNSServiceProcessResult(mdns_conn_sdref);
			break;
		}
	}

	TALLOC_FREE(fdset);
	DNSServiceRefDeallocate(mdns_conn_sdref);
}
示例#28
0
//methods to implement for concrete implementations
bool CZeroconfWIN::doPublishService(const std::string& fcr_identifier,
                      const std::string& fcr_type,
                      const std::string& fcr_name,
                      unsigned int f_port,
                      std::map<std::string, std::string> txt)
{
  DNSServiceRef netService = NULL;
  TXTRecordRef txtRecord;
  TXTRecordCreate(&txtRecord, 0, NULL);

  CLog::Log(LOGDEBUG, "CZeroconfWIN::doPublishService identifier: %s type: %s name:%s port:%i", fcr_identifier.c_str(), fcr_type.c_str(), fcr_name.c_str(), f_port);

  //add txt records
  if(!txt.empty())
  {
    for(std::map<std::string, std::string>::const_iterator it = txt.begin(); it != txt.end(); ++it)
    {
      CLog::Log(LOGDEBUG, "CZeroconfWIN: key:%s, value:%s",it->first.c_str(),it->second.c_str());
      uint8_t txtLen = (uint8_t)strlen(it->second.c_str());
      TXTRecordSetValue(&txtRecord, it->first.c_str(), txtLen, it->second.c_str());
    }
  }

  DNSServiceErrorType err = DNSServiceRegister(&netService, 0, 0, fcr_name.c_str(), fcr_type.c_str(), NULL, NULL, htons(f_port), TXTRecordGetLength(&txtRecord), TXTRecordGetBytesPtr(&txtRecord), registerCallback, NULL);

  if(err != kDNSServiceErr_ServiceNotRunning)
    DNSServiceProcessResult(netService);
  
  if (err != kDNSServiceErr_NoError)
  {
    // Something went wrong so lets clean up.
    if (netService)
      DNSServiceRefDeallocate(netService);

    CLog::Log(LOGERROR, "CZeroconfWIN::doPublishService CFNetServiceRegister returned (error = %ld)\n", (int) err);
    if(err == kDNSServiceErr_ServiceNotRunning)
    {
      CLog::Log(LOGERROR, "CZeroconfWIN: Zeroconf can't be started probably because Apple's Bonjour Service isn't installed. You can get it by either installing Itunes or Apple's Bonjour Print Service for Windows (http://support.apple.com/kb/DL999)");
      CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Error, "Failed to start zeroconf", "Is Apple's Bonjour Service installed? See log for more info.", 10000, true);
    }
  } 
  else
  {
    CSingleLock lock(m_data_guard);
    m_services.insert(make_pair(fcr_identifier, netService));
  }

  TXTRecordDeallocate(&txtRecord);

  return err == kDNSServiceErr_NoError;
}
void BonjourServiceResolver::bonjourSocketReadyRead()
{
    // If you remove the following line, this breaks on Lion. Why, you ask?
    // Because this will then be done in the socket notifier destructor, which
    // will be run in another thread because of QHostInfo::lookupHost().
    // Very likely a bug in the Qt multi-threading code.
    d->bonjourSocket->setEnabled(false);

    const DNSServiceErrorType err = DNSServiceProcessResult( d->dnssref );
    if( err != kDNSServiceErr_NoError )
    {
        error( err );
    }
}
示例#30
0
文件: dirsvc.c 项目: AndychenCL/cups
static void
dnssdUpdate(void)
{
  DNSServiceErrorType	sdErr;		/* Service discovery error */


  if ((sdErr = DNSServiceProcessResult(DNSSDMaster)) != kDNSServiceErr_NoError)
  {
    cupsdLogMessage(CUPSD_LOG_ERROR,
                    "DNS Service Discovery registration error %d!",
	            sdErr);
    dnssdStop();
  }
}