From 7df24c4dbfc46e9dc61fd42ecd99c1bcda0a83ab Mon Sep 17 00:00:00 2001 From: Apple Date: Wed, 28 Jun 2006 01:34:38 +0000 Subject: [PATCH] mDNSResponder-108.2.tar.gz --- .../PrinterSetupWizardSheet.cpp | 2 +- Clients/PrinterSetupWizard/SecondPage.cpp | 2 +- Clients/PrinterSetupWizard/ThirdPage.cpp | 2 +- Makefile | 2 +- mDNSMacOSX/SamplemDNSClient.c | 9 +++- .../mDNSResponder.pbproj/project.pbxproj | 9 +++- mDNSShared/Java/DNSSD.java | 15 ++++--- mDNSShared/Java/DNSSDException.java | 15 +++++++ mDNSShared/Java/JNISupport.c | 41 +++++++++++++------ mDNSShared/dns-sd.1 | 5 ++- mDNSShared/uds_daemon.c | 2 +- mDNSWindows/ControlPanel/SharedSecret.cpp | 2 +- mDNSWindows/SystemService/Service.c | 2 +- 13 files changed, 78 insertions(+), 30 deletions(-) diff --git a/Clients/PrinterSetupWizard/PrinterSetupWizardSheet.cpp b/Clients/PrinterSetupWizard/PrinterSetupWizardSheet.cpp index 34db548..6c0c9f3 100644 --- a/Clients/PrinterSetupWizard/PrinterSetupWizardSheet.cpp +++ b/Clients/PrinterSetupWizard/PrinterSetupWizardSheet.cpp @@ -27,7 +27,7 @@ Revision 1.34 2005/10/05 17:32:51 herscher Use a case insensitive compare operation to check whether a printer with the same name has already been installed. Revision 1.33 2005/07/11 20:17:15 shersche - UI fixes associated with CUPS printer workaround fix. + UI fixes associated with CUPS printer workaround fix. Revision 1.32 2005/07/07 17:53:20 shersche Fix problems associated with the CUPS printer workaround fix. diff --git a/Clients/PrinterSetupWizard/SecondPage.cpp b/Clients/PrinterSetupWizard/SecondPage.cpp index 3c9cedc..c64030d 100644 --- a/Clients/PrinterSetupWizard/SecondPage.cpp +++ b/Clients/PrinterSetupWizard/SecondPage.cpp @@ -27,7 +27,7 @@ Revision 1.18 2005/07/20 17:44:54 shersche UI fixes for CUPS workaround Revision 1.17 2005/07/11 20:17:15 shersche - UI fixes associated with CUPS printer workaround fix. + UI fixes associated with CUPS printer workaround fix. Revision 1.16 2005/07/07 17:53:20 shersche Fix problems associated with the CUPS printer workaround fix. diff --git a/Clients/PrinterSetupWizard/ThirdPage.cpp b/Clients/PrinterSetupWizard/ThirdPage.cpp index 3c55463..bf16fe2 100644 --- a/Clients/PrinterSetupWizard/ThirdPage.cpp +++ b/Clients/PrinterSetupWizard/ThirdPage.cpp @@ -27,7 +27,7 @@ Revision 1.27 2005/10/05 21:41:45 herscher Use "application/octet-stream" to determine if CUPS shared queue supports raw Revision 1.26 2005/07/11 20:17:15 shersche - UI fixes associated with CUPS printer workaround fix. + UI fixes associated with CUPS printer workaround fix. Revision 1.25 2005/07/07 17:53:20 shersche Fix problems associated with the CUPS printer workaround fix. diff --git a/Makefile b/Makefile index b6ce9e0..ce810eb 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ include /Developer/Makefiles/pb_makefiles/platform.make -MVERS = "mDNSResponder-108" +MVERS = "mDNSResponder-108.2" install: cd "$(SRCROOT)/mDNSMacOSX"; xcodebuild install OBJROOT=$(OBJROOT) SYMROOT=$(SYMROOT) DSTROOT=$(DSTROOT) MVERS=$(MVERS) diff --git a/mDNSMacOSX/SamplemDNSClient.c b/mDNSMacOSX/SamplemDNSClient.c index a387269..be60816 100644 --- a/mDNSMacOSX/SamplemDNSClient.c +++ b/mDNSMacOSX/SamplemDNSClient.c @@ -36,6 +36,9 @@ Change History (most recent first): $Log: SamplemDNSClient.c,v $ +Revision 1.47 2006/01/10 02:29:22 cheshire + Cosmetic IPv6 address display problem in mDNS test tool + Revision 1.46 2004/11/02 01:32:34 cheshire Update code so it still compiles when DNSServiceDiscovery.h is deprecated @@ -217,12 +220,14 @@ static void resolve_reply(struct sockaddr *interface, struct sockaddr *address, else if (address->sa_family == AF_INET6) { struct sockaddr_in6 *ip6 = (struct sockaddr_in6 *)address; - u_int16_t *w = ip6->sin6_addr.__u6_addr.__u6_addr16; + u_int8_t *b = ip6->sin6_addr.__u6_addr.__u6_addr8; union { uint16_t s; u_char b[2]; } port = { ip6->sin6_port }; uint16_t PortAsNumber = ((uint16_t)port.b[0]) << 8 | port.b[1]; char ipstring[40]; char ifname[IF_NAMESIZE + 1] = ""; - sprintf(ipstring, "%04X:%04X:%04X:%04X:%04X:%04X:%04X:%04X", w[0], w[1], w[2], w[3], w[4], w[5], w[6], w[7]); + sprintf(ipstring, "%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X", + b[0x0], b[0x1], b[0x2], b[0x3], b[0x4], b[0x5], b[0x6], b[0x7], + b[0x8], b[0x9], b[0xA], b[0xB], b[0xC], b[0xD], b[0xE], b[0xF]); if (ip6->sin6_scope_id) { ifname[0] = '%'; if_indextoname(ip6->sin6_scope_id, &ifname[1]); } printf("%s%s:%u", ipstring, ifname, PortAsNumber); } diff --git a/mDNSMacOSX/mDNSResponder.pbproj/project.pbxproj b/mDNSMacOSX/mDNSResponder.pbproj/project.pbxproj index 6c92377..1df3173 100644 --- a/mDNSMacOSX/mDNSResponder.pbproj/project.pbxproj +++ b/mDNSMacOSX/mDNSResponder.pbproj/project.pbxproj @@ -954,7 +954,8 @@ JAVA_ARCHIVE_COMPRESSION = YES; JAVA_ARCHIVE_TYPE = JAR; JAVA_COMPILER_DEBUGGING_SYMBOLS = NO; - JAVA_COMPILER_TARGET_VM_VERSION = 1.2; + JAVA_COMPILER_SOURCE_VERSION = 1.4; + JAVA_COMPILER_TARGET_VM_VERSION = 1.4; JAVA_SOURCE_SUBDIR = .; LIBRARY_STYLE = STATIC; MACOSX_DEPLOYMENT_TARGET = 10.2; @@ -966,6 +967,7 @@ PURE_JAVA = YES; REZ_EXECUTABLE = YES; SECTORDER_FLAGS = ""; + STRIPFLAGS = "-S"; WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; }; comments = "Multiplatform .jar file that implements Java interface to DNS-SD"; @@ -988,7 +990,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "if [ -d ${OBJROOT}/mDNSResponder.build/${CONFIGURATION} ]; then BUILD_DIR=${OBJROOT}/mDNSResponder.build/${CONFIGURATION}; else BUILD_DIR=${OBJROOT}/mDNSResponder.build; fi\njavah -force -classpath ${BUILD_DIR}/dns_sd.jar.build/JavaClasses/ -o ${BUILD_DIR}/dns_sd.jar.build/DNSSD.java.h com.apple.dnssd.AppleDNSSD com.apple.dnssd.AppleBrowser com.apple.dnssd.AppleResolver com.apple.dnssd.AppleRegistration com.apple.dnssd.AppleQuery com.apple.dnssd.AppleDomainEnum com.apple.dnssd.AppleService"; + shellScript = "if [ -d ${OBJROOT}/mDNSResponder.build/${CONFIGURATION} ]; then BUILD_DIR=${OBJROOT}/mDNSResponder.build/${CONFIGURATION}; else BUILD_DIR=${OBJROOT}/mDNSResponder.build; fi\njavah -force -J-Xbootclasspath/p:${BUILD_DIR}/dns_sd.jar.build/JavaClasses -o ${BUILD_DIR}/dns_sd.jar.build/DNSSD.java.h com.apple.dnssd.AppleDNSSD com.apple.dnssd.AppleBrowser com.apple.dnssd.AppleResolver com.apple.dnssd.AppleRegistration com.apple.dnssd.AppleQuery com.apple.dnssd.AppleDomainEnum com.apple.dnssd.AppleService"; }; DB2CC4560662DE4500335AB3 = { fileRef = DB2CC4430662DD1100335AB3; @@ -1113,6 +1115,7 @@ PRODUCT_NAME = libjdns_sd.jnilib; REZ_EXECUTABLE = YES; SECTORDER_FLAGS = ""; + STRIPFLAGS = "-S"; WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; }; comments = "Platform-specific JNI library that bridges dns_sd.jar to ."; @@ -1676,6 +1679,7 @@ PREBINDING = NO; PRODUCT_NAME = Bonjour; SECTORDER_FLAGS = ""; + STRIPFLAGS = "-S"; WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; WRAPPER_EXTENSION = prefPane; }; @@ -2219,6 +2223,7 @@ PRODUCT_NAME = ddnswriteconfig; REZ_EXECUTABLE = YES; SECTORDER_FLAGS = ""; + STRIPFLAGS = "-S"; WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; }; dependencies = ( diff --git a/mDNSShared/Java/DNSSD.java b/mDNSShared/Java/DNSSD.java index d8a7ce1..50d29e4 100644 --- a/mDNSShared/Java/DNSSD.java +++ b/mDNSShared/Java/DNSSD.java @@ -23,6 +23,9 @@ Change History (most recent first): $Log: DNSSD.java,v $ +Revision 1.9 2005/10/26 01:52:24 cheshire + Race condition in Java code (doesn't work at all on Linux) + Revision 1.8 2005/07/11 01:55:21 cheshire Race condition in Java API @@ -652,8 +655,8 @@ class AppleService implements DNSSDService, Runnable public void stop() { this.HaltOperation(); } - /* Block for timeout ms (or forever if -1). Returns 1 if data present, 0 if timed out, -1 if not browsing. */ - protected native int BlockForData( int msTimeout); + /* Block until data arrives, or one second passes. Returns 1 if data present, 0 otherwise. */ + protected native int BlockForData(); /* Call ProcessResults when data appears on socket descriptor. */ protected native int ProcessResults(); @@ -672,7 +675,9 @@ class AppleService implements DNSSDService, Runnable { while ( true ) { - // We have to be very careful here. Suppose our DNS-SD operation is stopped from some other thread, + // Note: We want to allow our DNS-SD operation to be stopped from other threads, so we have to + // block waiting for data *outside* the synchronized section. Because we're doing this unsynchronized + // we have to write some careful code. Suppose our DNS-SD operation is stopped from some other thread, // and then immediately afterwards that thread (or some third, unrelated thread) starts a new DNS-SD // operation. The Unix kernel always allocates the lowest available file descriptor to a new socket, // so the same file descriptor is highly likely to be reused for the new operation, and if our old @@ -691,11 +696,11 @@ class AppleService implements DNSSDService, Runnable // locking DOESN'T prevent the callback routine from stopping its own operation, but DOES prevent // any other thread from stopping it until after the callback has completed and returned to us here. - int result = BlockForData(-1); - if (result != 1) break; // If socket has been closed, time to terminate this thread + int result = BlockForData(); synchronized (this) { if (fNativeContext == 0) break; // Some other thread stopped our DNSSD operation; time to terminate this thread + if (result == 0) continue; // If BlockForData() said there was no data, go back and block again result = ProcessResults(); if (fNativeContext == 0) break; // Event listener stopped its own DNSSD operation; terminate this thread if (result != 0) { fListener.operationFailed(this, result); break; } // If error, notify listener diff --git a/mDNSShared/Java/DNSSDException.java b/mDNSShared/Java/DNSSDException.java index 595e405..0ab0587 100644 --- a/mDNSShared/Java/DNSSDException.java +++ b/mDNSShared/Java/DNSSDException.java @@ -23,6 +23,9 @@ Change History (most recent first): $Log: DNSSDException.java,v $ +Revision 1.3 2005/07/10 22:19:01 cheshire +Add missing error codes to list of public static final ints + Revision 1.2 2004/04/30 21:48:27 rpantos Change line endings for CVS. @@ -50,11 +53,23 @@ abstract public class DNSSDException extends Exception public static final int BAD_FLAGS = -65543; public static final int UNSUPPORTED = -65544; public static final int NOT_INITIALIZED = -65545; + public static final int NO_CACHE = -65546; public static final int ALREADY_REGISTERED = -65547; public static final int NAME_CONFLICT = -65548; public static final int INVALID = -65549; + public static final int FIREWALL = -65550; public static final int INCOMPATIBLE = -65551; public static final int BAD_INTERFACE_INDEX = -65552; + public static final int REFUSED = -65553; + public static final int NOSUCHRECORD = -65554; + public static final int NOAUTH = -65555; + public static final int NOSUCHKEY = -65556; + public static final int NATTRAVERSAL = -65557; + public static final int DOUBLENAT = -65558; + public static final int BADTIME = -65559; + public static final int BADSIG = -65560; + public static final int BADKEY = -65561; + public static final int TRANSIENT = -65562; /** Returns the sub-code that identifies the particular error. */ abstract public int getErrorCode(); diff --git a/mDNSShared/Java/JNISupport.c b/mDNSShared/Java/JNISupport.c index 902e85d..d7c6243 100644 --- a/mDNSShared/Java/JNISupport.c +++ b/mDNSShared/Java/JNISupport.c @@ -23,6 +23,9 @@ Change History (most recent first): $Log: JNISupport.c,v $ +Revision 1.13 2005/10/26 01:52:24 cheshire + Race condition in Java code (doesn't work at all on Linux) + Revision 1.12 2005/07/13 19:20:32 cheshire Race condition in Java API Additional cleanup suggested by Roger -- NewContext() doesn't need ownerClass parameter any more @@ -262,15 +265,13 @@ JNIEXPORT void JNICALL Java_com_apple_dnssd_AppleService_HaltOperation( JNIEnv * } -JNIEXPORT jint JNICALL Java_com_apple_dnssd_AppleService_BlockForData( JNIEnv *pEnv, jobject pThis, jint msTimeout) -/* Block for timeout ms (or forever if -1). Returns 1 if data present, 0 if timed out, -1 if not browsing. */ +JNIEXPORT jint JNICALL Java_com_apple_dnssd_AppleService_BlockForData( JNIEnv *pEnv, jobject pThis) +/* Block until data arrives, or one second passes. Returns 1 if data present, 0 otherwise. */ { -#if AUTO_CALLBACKS - return -1; // BlockForData() not supported with AUTO_CALLBACKS -#else // AUTO_CALLBACKS +// BlockForData() not supported with AUTO_CALLBACKS +#if !AUTO_CALLBACKS jclass cls = (*pEnv)->GetObjectClass( pEnv, pThis); jfieldID contextField = (*pEnv)->GetFieldID( pEnv, cls, "fNativeContext", "I"); - jint rc = -1; if ( contextField != 0) { @@ -279,18 +280,32 @@ JNIEXPORT jint JNICALL Java_com_apple_dnssd_AppleService_BlockForData( JNIEnv *p { fd_set readFDs; int sd = DNSServiceRefSockFD( pContext->ServiceRef); - struct timeval timeout = { msTimeout / 1000, 10 * (msTimeout % 1000) }; - struct timeval *pTimeout = msTimeout == -1 ? NULL : &timeout; - + struct timeval timeout = { 1, 0 }; FD_ZERO( &readFDs); FD_SET( sd, &readFDs); - rc = select( sd + 1, &readFDs, (fd_set*) NULL, (fd_set*) NULL, pTimeout); + // Q: Why do we poll here? + // A: Because there's no other thread-safe way to do it. + // Mac OS X terminates a select() call if you close one of the sockets it's listening on, but Linux does not, + // and arguably Linux is correct (See ) + // The problem is that the Mac OS X behaviour assumes that it's okay for one thread to close a socket while + // some other thread is monitoring that socket in select(), but the difficulty is that there's no general way + // to make that thread-safe, because there's no atomic way to enter select() and release a lock simultaneously. + // If we try to do this without holding any lock, then right as we jump to the select() routine, + // some other thread could stop our operation (thereby closing the socket), + // and then that thread (or even some third, unrelated thread) + // could do some other DNS-SD operation (or some other operation that opens a new file descriptor) + // and then we'd blindly resume our fall into the select() call, now blocking on a file descriptor + // that may coincidentally have the same numerical value, but is semantically unrelated + // to the true file descriptor we thought we were blocking on. + // We can't stop this race condition from happening, but at least if we wake up once a second we can detect + // when fNativeContext has gone to zero, and thereby discover that we were blocking on the wrong fd. + + if (select( sd + 1, &readFDs, (fd_set*) NULL, (fd_set*) NULL, &timeout) == 1) return(1); } } - - return rc; -#endif // AUTO_CALLBACKS +#endif // !AUTO_CALLBACKS + return(0); } diff --git a/mDNSShared/dns-sd.1 b/mDNSShared/dns-sd.1 index 3611200..6089ae6 100644 --- a/mDNSShared/dns-sd.1 +++ b/mDNSShared/dns-sd.1 @@ -20,6 +20,9 @@ .\" @APPLE_LICENSE_HEADER_END@ .\" .\" $Log: dns-sd.1,v $ +.\" Revision 1.5 2005/07/04 23:12:35 cheshire +.\" The dns-sd command first appeared in Mac OS X 10.4 (Tiger) +.\" .\" Revision 1.4 2005/02/16 02:29:32 cheshire .\" Update terminology .\" @@ -211,4 +214,4 @@ bugs are tracked in Apple Radar component "mDNSResponder". .Sh HISTORY The .Nm -command first appeared in Mac OS X 10.3 (Panther). +command first appeared in Mac OS X 10.4 (Tiger). diff --git a/mDNSShared/uds_daemon.c b/mDNSShared/uds_daemon.c index 406b7ab..86ea294 100644 --- a/mDNSShared/uds_daemon.c +++ b/mDNSShared/uds_daemon.c @@ -546,7 +546,7 @@ Revision 1.25 2003/10/22 23:37:49 ksekar : crash/hang in abort_client Revision 1.24 2003/10/21 20:59:40 ksekar -: handle blocked clients moreefficiently +: handle blocked clients more efficiently Revision 1.23 2003/09/23 02:12:43 cheshire Also include port number in list of services registered via new UDS API diff --git a/mDNSWindows/ControlPanel/SharedSecret.cpp b/mDNSWindows/ControlPanel/SharedSecret.cpp index 8f0260b..7ba6a2a 100644 --- a/mDNSWindows/ControlPanel/SharedSecret.cpp +++ b/mDNSWindows/ControlPanel/SharedSecret.cpp @@ -128,7 +128,7 @@ CSharedSecret::Commit( CString zone ) m_key += '.'; } - // + // // // Prepend "$" to the key name, so that there will // be no conflict between the zone name and the key diff --git a/mDNSWindows/SystemService/Service.c b/mDNSWindows/SystemService/Service.c index f85b176..768b589 100644 --- a/mDNSWindows/SystemService/Service.c +++ b/mDNSWindows/SystemService/Service.c @@ -30,7 +30,7 @@ Revision 1.37 2005/10/05 18:05:28 herscher Save Wide-Area preferences in a different spot in the registry so they don't get removed when doing an update install. Revision 1.36 2005/09/11 22:12:42 herscher - Remove dependency on WMI. Ensure that the Windows firewall is turned on before trying to configure it. + Remove dependency on WMI. Ensure that the Windows firewall is turned on before trying to configure it. Revision 1.35 2005/06/30 18:29:49 shersche Don't overwrite the localized service description text -- 2.47.2