Index: configure.in =================================================================== RCS file: /cvsroot/pgsql/configure.in,v retrieving revision 1.609 diff -c -r1.609 configure.in *** configure.in 26 Aug 2009 22:24:42 -0000 1.609 --- configure.in 7 Sep 2009 03:00:24 -0000 *************** *** 1066,1072 **** fi if test "$with_bonjour" = yes ; then ! AC_CHECK_HEADER(DNSServiceDiscovery/DNSServiceDiscovery.h, [], [AC_MSG_ERROR([header file is required for Bonjour])]) fi # for contrib/uuid-ossp --- 1066,1072 ---- fi if test "$with_bonjour" = yes ; then ! AC_CHECK_HEADER(dns_sd.h, [], [AC_MSG_ERROR([header file is required for Bonjour])]) fi # for contrib/uuid-ossp Index: src/backend/postmaster/postmaster.c =================================================================== RCS file: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v retrieving revision 1.594 diff -c -r1.594 postmaster.c *** src/backend/postmaster/postmaster.c 31 Aug 2009 19:41:00 -0000 1.594 --- src/backend/postmaster/postmaster.c 7 Sep 2009 03:00:24 -0000 *************** *** 89,95 **** #endif #ifdef USE_BONJOUR ! #include #endif #include "access/transam.h" --- 89,95 ---- #endif #ifdef USE_BONJOUR ! #include #endif #include "access/transam.h" *************** *** 309,324 **** extern int optreset; /* might not be declared by system headers */ #endif /* * postmaster.c - function prototypes */ static void getInstallationPaths(const char *argv0); static void checkDataDir(void); - - #ifdef USE_BONJOUR - static void reg_reply(DNSServiceRegistrationReplyErrorType errorCode, - void *context); - #endif static void pmdaemonize(void); static Port *ConnCreate(int serverFd); static void ConnFree(Port *port); --- 309,323 ---- extern int optreset; /* might not be declared by system headers */ #endif + #ifdef USE_BONJOUR + static DNSServiceRef bonjour_sdref = NULL; + #endif + /* * postmaster.c - function prototypes */ static void getInstallationPaths(const char *argv0); static void checkDataDir(void); static void pmdaemonize(void); static Port *ConnCreate(int serverFd); static void ConnFree(Port *port); *************** *** 855,869 **** #ifdef USE_BONJOUR /* Register for Bonjour only if we opened TCP socket(s) */ ! if (ListenSocket[0] != -1 && bonjour_name != NULL) { ! DNSServiceRegistrationCreate(bonjour_name, ! "_postgresql._tcp.", ! "", ! htons(PostPortNumber), ! "", ! (DNSServiceRegistrationReply) reg_reply, ! NULL); } #endif --- 854,891 ---- #ifdef USE_BONJOUR /* Register for Bonjour only if we opened TCP socket(s) */ ! if (ListenSocket[0] != -1) { ! DNSServiceErrorType err; ! ! /* ! * We pass 0 for interface_index, which will result in registering ! * for all available interfaces. It's not entirely clear from the ! * DNS-SD docs whether this would be appropriate if we have bound ! * to just a subset of the available interfaces. ! */ ! err = DNSServiceRegister(&bonjour_sdref, ! 0, ! 0, ! bonjour_name, ! "_postgresql._tcp.", ! NULL, ! NULL, ! htons(PostPortNumber), ! 0, ! NULL, ! NULL, ! NULL); ! if (err != kDNSServiceErr_NoError) ! elog(LOG, "DNSServiceRegister() failed: error code %ld", ! (long) err); ! /* ! * We don't bother to read the mDNS daemon's reply, and we expect ! * that it will automatically terminate our registration when the ! * socket is closed at postmaster termination. So there's nothing ! * more to be done here. However, the bonjour_sdref is kept around ! * so that forked children can close their copies of the socket. ! */ } #endif *************** *** 1192,1209 **** } - #ifdef USE_BONJOUR - - /* - * empty callback function for DNSServiceRegistrationCreate() - */ - static void - reg_reply(DNSServiceRegistrationReplyErrorType errorCode, void *context) - { - } - #endif /* USE_BONJOUR */ - - /* * Fork away from the controlling terminal (silent_mode option) * --- 1214,1219 ---- *************** *** 2004,2009 **** --- 2014,2025 ---- syslogPipe[0] = 0; #endif } + + #ifdef USE_BONJOUR + /* If using Bonjour, close the connection to the mDNS daemon */ + if (bonjour_sdref) + close(DNSServiceRefSockFD(bonjour_sdref)); + #endif }