Index: scheduler/sysman.c =================================================================== --- scheduler/sysman.c (revision 6073) +++ scheduler/sysman.c (working copy) @@ -115,12 +115,18 @@ /* The runloop. Access must be protected! */ static CFStringRef ComputerNameKey = NULL, /* Computer name key */ - NetworkGlobalKey = NULL, - /* Network global key */ + NetworkGlobalKeyIPv4 = NULL, + /* Network global IPv4 key */ + NetworkGlobalKeyIPv6 = NULL, + /* Network global IPv6 key */ + NetworkGlobalKeyDNS = NULL, + /* Network global DNS key */ HostNamesKey = NULL, /* Host name key */ - NetworkInterfaceKey = NULL; + NetworkInterfaceKeyIPv4 = NULL, /* Netowrk interface key */ + NetworkInterfaceKeyIPv6 = NULL; + /* Netowrk interface key */ /* @@ -306,7 +312,6 @@ } else { - /* TODO: Possibly update when MDNS support is added? */ cupsdLogMessage(CUPSD_LOG_DEBUG, "Deregistering local printer \"%s\"", p->name); cupsdSendBrowseDelete(p); @@ -334,12 +339,6 @@ "System network configuration changed"); /* - * Force an update of the list of network interfaces in 2 seconds. - */ - - NetIFTime = time(NULL) - 58; - - /* * Resetting browse_time before calling cupsdSendBrowseList causes * browse packets to be sent for local shared printers. */ @@ -407,8 +406,8 @@ SCDynamicStoreRef store = NULL;/* System Config dynamic store */ CFRunLoopSourceRef powerRLS = NULL,/* Power runloop source */ storeRLS = NULL;/* System Config runloop source */ - CFStringRef key[3], /* System Config keys */ - pattern[1]; /* System Config patterns */ + CFStringRef key[5], /* System Config keys */ + pattern[2]; /* System Config patterns */ CFArrayRef keys = NULL, /* System Config key array*/ patterns = NULL;/* System Config pattern array */ SCDynamicStoreContext storeContext; /* Dynamic store context */ @@ -449,33 +448,58 @@ if (!ComputerNameKey) ComputerNameKey = SCDynamicStoreKeyCreateComputerName(NULL); - if (!NetworkGlobalKey) - NetworkGlobalKey = + if (!NetworkGlobalKeyIPv4) + NetworkGlobalKeyIPv4 = SCDynamicStoreKeyCreateNetworkGlobalEntity(NULL, kSCDynamicStoreDomainState, kSCEntNetIPv4); + if (!NetworkGlobalKeyIPv6) + NetworkGlobalKeyIPv6 = + SCDynamicStoreKeyCreateNetworkGlobalEntity(NULL, + kSCDynamicStoreDomainState, + kSCEntNetIPv6); + + if (!NetworkGlobalKeyDNS) + NetworkGlobalKeyDNS = + SCDynamicStoreKeyCreateNetworkGlobalEntity(NULL, + kSCDynamicStoreDomainState, + kSCEntNetDNS); + if (!HostNamesKey) HostNamesKey = SCDynamicStoreKeyCreateHostNames(NULL); - if (!NetworkInterfaceKey) - NetworkInterfaceKey = + if (!NetworkInterfaceKeyIPv4) + NetworkInterfaceKeyIPv4 = SCDynamicStoreKeyCreateNetworkInterfaceEntity(NULL, kSCDynamicStoreDomainState, kSCCompAnyRegex, kSCEntNetIPv4); - if (store && ComputerNameKey && NetworkGlobalKey && HostNamesKey && - NetworkInterfaceKey) + if (!NetworkInterfaceKeyIPv6) + NetworkInterfaceKeyIPv6 = + SCDynamicStoreKeyCreateNetworkInterfaceEntity(NULL, + kSCDynamicStoreDomainState, + kSCCompAnyRegex, + kSCEntNetIPv6); + + if (store && ComputerNameKey && HostNamesKey && + NetworkGlobalKeyIPv4 && NetworkGlobalKeyIPv6 && NetworkGlobalKeyDNS && + NetworkInterfaceKeyIPv4 && NetworkInterfaceKeyIPv6) { key[0] = ComputerNameKey; - key[1] = NetworkGlobalKey; - key[2] = HostNamesKey; - pattern[0] = NetworkInterfaceKey; + key[1] = NetworkGlobalKeyIPv4; + key[2] = NetworkGlobalKeyIPv6; + key[3] = NetworkGlobalKeyDNS; + key[4] = HostNamesKey; + pattern[0] = NetworkInterfaceKeyIPv4; + pattern[1] = NetworkInterfaceKeyIPv6; + keys = CFArrayCreate(NULL, (const void **)key, sizeof(key) / sizeof(key[0]), &kCFTypeArrayCallBacks); + patterns = CFArrayCreate(NULL, (const void **)pattern, sizeof(pattern) / sizeof(pattern[0]), &kCFTypeArrayCallBacks); @@ -682,12 +706,17 @@ if (CFArrayContainsValue(changedKeys, range, ComputerNameKey)) threadData->sysevent.event |= SYSEVENT_NAMECHANGED; - - if (CFArrayContainsValue(changedKeys, range, NetworkGlobalKey) || - CFArrayContainsValue(changedKeys, range, HostNamesKey) || - CFArrayContainsValue(changedKeys, range, NetworkInterfaceKey)) + else + { threadData->sysevent.event |= SYSEVENT_NETCHANGED; + /* + * Indicate the network interface list needs updating... + */ + + NetIFUpdate = 1; + } + /* * Because we registered for several different kinds of change notifications * this callback usually gets called several times in a row. We use a timer to @@ -695,7 +724,7 @@ */ CFRunLoopTimerSetNextFireDate(threadData->timerRef, - CFAbsoluteTimeGetCurrent() + 2); + CFAbsoluteTimeGetCurrent() + 5); } Index: scheduler/network.c =================================================================== --- scheduler/network.c (revision 6073) +++ scheduler/network.c (working copy) @@ -112,6 +112,17 @@ char hostname[1024]; /* Hostname for address */ +#ifdef __APPLE__ +/* + * NetIFUpdate is set whenever the SystemConfiguration framework indicates + * there's been a change to the networking stack. + */ + + if (!NetIFUpdate) + return; + + NetIFUpdate = 0; +#else /* * Update the network interface list no more often than once a * minute... @@ -121,6 +132,7 @@ return; NetIFTime = time(NULL); +#endif /* __APPLE__ */ /* * Free the old interfaces... Index: scheduler/network.h =================================================================== --- scheduler/network.h (revision 6073) +++ scheduler/network.h (working copy) @@ -43,8 +43,14 @@ * Globals... */ +#ifdef __APPLE__ +VAR int NetIFUpdate VALUE(1); + /* Network interface list needs updating */ +#else VAR time_t NetIFTime VALUE(0); /* Network interface list time */ +#endif /* __APPLE__ */ + VAR cups_array_t *NetIFList VALUE(NULL); /* Array of network interfaces */