Пример #1
0
void AvahiQuerier::stop() {
    assert(threadedPoll);
    avahi_threaded_poll_stop(threadedPoll);
    assert(client);
    avahi_client_free(client);
    avahi_threaded_poll_free(threadedPoll);
}
Пример #2
0
void avahi_cleanup(void) {
if (db) fprintf(stderr, "in  avahi_cleanup\n");
	if (!_client) {
if (db) fprintf(stderr, "    avahi_cleanup client null\n");
		return;
	}
if (db) fprintf(stderr, "    avahi_cleanup poll_lock\n");
	avahi_threaded_poll_lock(_poll);
if (db) fprintf(stderr, "    avahi_cleanup poll_stop\n");

	signal(SIGALRM, avahi_timeout);
	alarm(3);
	avahi_threaded_poll_stop(_poll);
	alarm(0);
	signal(SIGALRM, SIG_DFL);

if (db) fprintf(stderr, "    avahi_cleanup client_free\n");
	avahi_client_free(_client);
	_client = NULL;

if (db) fprintf(stderr, "    avahi_cleanup poll_free\n");
	avahi_threaded_poll_free(_poll);
	_poll = NULL;
if (db) fprintf(stderr, "out avahi_cleanup\n");
}
Пример #3
0
void dns_service_publisher_stop( void )
{
	if( threaded_poll )
	{
		avahi_threaded_poll_stop( threaded_poll );
	}

	dns_service_publisher_cleanup();
}
Пример #4
0
static void avahi_unregister(void) {
  debug(1, "avahi: avahi_unregister.");
  if (tpoll)
    avahi_threaded_poll_stop(tpoll);
  tpoll = NULL;

  if (service_name)
    free(service_name);
  service_name = NULL;
}
Пример #5
0
/** Called from outside of thread to stop operations.
 */
void Publisher::stop() {
	if (running) {
		int error = avahi_threaded_poll_stop(poller);
		if (error < 0) {
			std::cerr << "Error stopping avahi threaded poll ("
					<< avahi_strerror(error) << ")" << std::endl;
		}
		running = false;
	}
}
Пример #6
0
/*****************************************************************************
 * Close: cleanup
 *****************************************************************************/
static void Close( vlc_object_t *p_this )
{
    services_discovery_t *p_sd = ( services_discovery_t* )p_this;
    services_discovery_sys_t *p_sys = p_sd->p_sys;
    avahi_threaded_poll_stop( p_sys->poll );

    avahi_client_free( p_sys->client );
    avahi_threaded_poll_free( p_sys->poll );

    vlc_dictionary_clear( &p_sys->services_name_to_input_item, NULL, NULL );
    free( p_sys );
}
Пример #7
0
static void
dnssdStop(void)
{
  cupsd_printer_t	*p;		/* Current printer */


 /*
  * De-register the individual printers
  */

  for (p = (cupsd_printer_t *)cupsArrayFirst(Printers);
       p;
       p = (cupsd_printer_t *)cupsArrayNext(Printers))
    dnssdDeregisterPrinter(p, 1, 0);

 /*
  * Shutdown the rest of the service refs...
  */

  dnssdDeregisterInstance(&WebIFSrv, 0);

#  ifdef HAVE_DNSSD
  cupsdRemoveSelect(DNSServiceRefSockFD(DNSSDMaster));

  DNSServiceRefDeallocate(DNSSDMaster);
  DNSSDMaster = NULL;

#  else /* HAVE_AVAHI */
  if (DNSSDMaster)
    avahi_threaded_poll_stop(DNSSDMaster);

  if (DNSSDClient)
  {
    avahi_client_free(DNSSDClient);
    DNSSDClient = NULL;
  }

  if (DNSSDMaster)
  {
    avahi_threaded_poll_free(DNSSDMaster);
    DNSSDMaster = NULL;
  }
#  endif /* HAVE_DNSSD */

  cupsArrayDelete(DNSSDPrinters);
  DNSSDPrinters = NULL;

  DNSSDPort = 0;
}
Пример #8
0
AvahiSession::~AvahiSession()
{
	if (mClient) {
		avahi_threaded_poll_stop(mPoll);
		avahi_client_free(mClient);
		avahi_threaded_poll_free(mPoll);
		AvahiEntry* entry = mEntries;
		while (entry) {
			AvahiEntry* next = entry->mNext;
			delete entry;
			entry = next;
		}
	}
	free(mServiceName);
}
Пример #9
0
/*
 * Tries to shutdown this loop impl.
 * Call this function from inside this thread.
 */
int av_zeroconf_unregister() {
    LOG(log_debug, logtype_afpd, "av_zeroconf_unregister");

    if (ctx) {
        if (ctx->threaded_poll)
            avahi_threaded_poll_stop(ctx->threaded_poll);
        if (ctx->client)
            avahi_client_free(ctx->client);
        if (ctx->threaded_poll)
            avahi_threaded_poll_free(ctx->threaded_poll);
        free(ctx);
        ctx = NULL;
    }
    return 0;
}
Пример #10
0
/*
 * Tries to shutdown this loop impl.
 * Call this function from inside this thread.
 */
void tivo_bonjour_unregister(void)
{
	DPRINTF(E_DEBUG, L_SSDP, "tivo_bonjour_unregister\n");

	if (ctx.group)
	{
		avahi_entry_group_reset(ctx.group);
		avahi_entry_group_free(ctx.group);
	}
	if (ctx.threaded_poll)
		avahi_threaded_poll_stop(ctx.threaded_poll);
	if (ctx.client)
		avahi_client_free(ctx.client);
	if (ctx.threaded_poll)
		avahi_threaded_poll_free(ctx.threaded_poll);
}
Пример #11
0
void avahi_dacp_dont_monitor(rtsp_conn_info *conn) {
  dacp_browser_struct *dbs = (dacp_browser_struct *)conn->mdns_private_pointer;
  if (dbs) {
    // stop and dispose of everything
    if ((dbs)->service_poll)
      avahi_threaded_poll_stop((dbs)->service_poll);
    if ((dbs)->service_browser)
      avahi_service_browser_free((dbs)->service_browser);
    if ((dbs)->service_client)
      avahi_client_free((dbs)->service_client);
    if ((dbs)->service_poll)
      avahi_threaded_poll_free((dbs)->service_poll);
    free((char *)(dbs));
    conn->mdns_private_pointer = NULL;
  } else {
    debug(1, "DHCP Monitor is not running.");
  }
}
Пример #12
0
void
dnssd_shutdown() {

  if (g_options.dnssd_data->DNSSDMaster) {
    avahi_threaded_poll_stop(g_options.dnssd_data->DNSSDMaster);
    dnssd_unregister();
  }

  if (g_options.dnssd_data->DNSSDClient) {
    avahi_client_free(g_options.dnssd_data->DNSSDClient);
    g_options.dnssd_data->DNSSDClient = NULL;
  }

  if (g_options.dnssd_data->DNSSDMaster) {
    avahi_threaded_poll_free(g_options.dnssd_data->DNSSDMaster);
    g_options.dnssd_data->DNSSDMaster = NULL;
  }

  free(g_options.dnssd_data);
  NOTE("DNS-SD shut down.");
}
Пример #13
0
/* Unregister this server from DNS-SD/mDNS */
int dcc_zeroconf_unregister(void *u) {
    struct context *ctx = u;

    if (ctx->threaded_poll)
        avahi_threaded_poll_stop(ctx->threaded_poll);

    if (ctx->client)
        avahi_client_free(ctx->client);

    if (ctx->threaded_poll)
        avahi_threaded_poll_free(ctx->threaded_poll);

    if (ctx->name)
        avahi_free(ctx->name);

    if (ctx->service_type)
        free(ctx->service_type);

    free(ctx);

    return 0;
}
Пример #14
0
int wxAvahiThreadPool::Stop(){
    return avahi_threaded_poll_stop(m_pool);
}
Пример #15
0
void stopAvahiClient(AvahiThreadedPoll *threaded_poll, AvahiClient *client) {
  avahi_threaded_poll_stop(threaded_poll);
  avahi_client_free(client);
  avahi_threaded_poll_free(threaded_poll);
}
Пример #16
0
int main( AVAHI_GCC_UNUSED int argc, char *argv[] )
{
    AvahiClient *client = NULL;
    AvahiServiceBrowser *serviceBrowser = NULL;
    char       *myName;
    int         error;
    int         result = 1;
    TiVoUnit   *tivo;

    myName = strrchr(argv[0], '/') + 1;
    if (myName == (NULL+1))
        myName = argv[0];

    openlog( myName, LOG_PID, LOG_DAEMON );
    loginfo("started");

    /* must be done before any threads start */
    curl_global_init( CURL_GLOBAL_ALL );

    /* Allocate main loop object */
    bonjourThread = avahi_threaded_poll_new();
    if ( !bonjourThread )
    {
        logerror( "Failed to create threaded poll object." );
    }
    else
    {
        /* Allocate a new client */
        client = avahi_client_new( avahi_threaded_poll_get( bonjourThread ), 0, client_callback, NULL, &error );

        /* Check wether creating the client object succeeded */
        if ( !client )
        {
            logerror( "Unable to create client: %s", avahi_strerror( error ) );
        }
        else
        {
            /* Create the service browser */
            serviceBrowser = avahi_service_browser_new( client,
                                                        AVAHI_IF_UNSPEC,
                                                        AVAHI_PROTO_UNSPEC,
                                                        "_tivo-device._tcp",
                                                        NULL, 0,
                                                        browseCallback, client );
            if ( !serviceBrowser )
            {
                logerror( "Unable to create service browser: %s", avahi_strerror( avahi_client_errno( client ) ) );
            }
            else
            {
                /* start the background network scan for TiVos */
                avahi_threaded_poll_start( bonjourThread );

                /* hack: wait for some results to arrive */
                sleep(5);
                /* what did we find? */
                result = dumpTiVos();

                avahi_threaded_poll_stop( bonjourThread );
                avahi_service_browser_free( serviceBrowser );
            }
            avahi_client_free( client );
        }
        avahi_threaded_poll_free( bonjourThread );
    }

    /* docs say no other threads may be running */
    curl_global_cleanup();

    loginfo( "stopped" );
    closelog();

    return result;
}