From 90d3cd8929932fb7698f8e56d0aa433df1192ff6 Mon Sep 17 00:00:00 2001 From: Ron Pedde Date: Mon, 1 Dec 2003 06:18:47 +0000 Subject: [PATCH] Finally _really_ fixed OSX advertisements via rendezvous --- configure.in | 2 ++ src/rend-osx.c | 38 +++++++++++++++++++++++--------------- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/configure.in b/configure.in index 7e2d8285..e150bc73 100644 --- a/configure.in +++ b/configure.in @@ -29,6 +29,8 @@ case $host in CPPFLAGS="$CPPFLAGS -DHAVE_SOCKLEN_T"; LDFLAGS="$LDFLAGS -lefence";; *darwin*) CPPFLAGS="$CPPFLAGS -no-cpp-precomp -DHAVE_SOCKADDR_SA_LEN -DHAVE_SOCKLEN_T" + LDFLAGS="$LDFLAGS -framework CoreFoundation" + AM_CONDITIONAL(COND_REND_OSX,true) AM_CONDITIONAL(COND_REND_HOWL,false) AM_CONDITIONAL(COND_REND_POSIX,false);; diff --git a/src/rend-osx.c b/src/rend-osx.c index 2d44c1a8..3df6149b 100644 --- a/src/rend-osx.c +++ b/src/rend-osx.c @@ -10,9 +10,11 @@ #include "err.h" +CFRunLoopRef rend_runloop; + static void rend_stoprunloop(void) { - CFRunLoopStop(CFRunLoopGetCurrent()); + CFRunLoopStop(rend_runloop); } static void rend_sigint(int sigraised) { @@ -64,31 +66,37 @@ static void rend_reply(DNSServiceRegistrationReplyErrorType errorCode, void *con int rend_init(pid_t *pid, char *name, int port) { dns_service_discovery_ref daap_ref=NULL; dns_service_discovery_ref http_ref=NULL; - - signal(SIGINT, rend_sigint); // SIGINT is what you get for a Ctrl-C - - - DPRINTF(ERR_DEBUG,"Registering services\n"); - - daap_ref=DNSServiceRegistrationCreate(name,"_daap._tcp",".local",port,"",rend_reply,nil); - http_ref=DNSServiceRegistrationCreate(name,"_http._tcp",".local",port,"",rend_reply,nil); - - if(rend_addtorunloop(daap_ref) || rend_addtorunloop(http_ref)) { - DPRINTF(ERR_WARN,"Add to runloop failed\n"); - return -1; - } + unsigned short usPort=port; *pid=fork(); if(*pid) { return 0; } + signal(SIGINT, rend_sigint); // SIGINT is what you get for a Ctrl-C + + + DPRINTF(ERR_DEBUG,"Registering services\n"); + + daap_ref=DNSServiceRegistrationCreate(name,"_daap._tcp","",usPort,"",rend_reply,nil); + http_ref=DNSServiceRegistrationCreate(name,"_http._tcp","",port,"",rend_reply,nil); + + if(rend_addtorunloop(daap_ref)|| rend_addtorunloop(http_ref)) { + DPRINTF(ERR_WARN,"Add to runloop failed\n"); + return -1; + } + + rend_runloop = CFRunLoopGetCurrent(); + + DPRINTF(ERR_DEBUG,"Registered rendezvous services\n"); CFRunLoopRun(); + DPRINTF(ERR_DEBUG,"Exiting runloop\n"); + DNSServiceDiscoveryDeallocate(daap_ref); DNSServiceDiscoveryDeallocate(http_ref); - return 0; + exit(0); }