New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved network interface support on MacOSX #2085

Closed
michaelrsweet opened this Issue Nov 7, 2006 · 2 comments

Comments

Projects
None yet
1 participant
@michaelrsweet
Collaborator

michaelrsweet commented Nov 7, 2006

Version: 1.2-current
CUPS.org User: jlovell

Improved network interface support on MacOSX

  • Add IPv6 and DNS to the list of SystemConfiguration events to monitor.
  • Only update the network interface list after SystemConfiguration sends a change event (i.e. don't update it every minute).
  • SystemConfiguration event matching was missing some events (wasn't matching patterns correctly).
  • Increase event coalescing delay from 2 seconds to 5.

See attached patch.

Thanks.

@michaelrsweet

This comment has been minimized.

Collaborator

michaelrsweet commented Nov 14, 2006

CUPS.org User: mike

OK, I've tweaked your changes slightly - basically, now we'll depend on NetIFUpdate on all platforms, with the old timeout logic being used on operating systems without the system management support. That should make adding the D-BUS stuff for Linux simpler (they have a similar set of network change notifications now) and limits the number of time() calls we do otherwise...

@michaelrsweet

This comment has been minimized.

Collaborator

michaelrsweet commented Nov 14, 2006

"sysman.patch":

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 */

@michaelrsweet michaelrsweet added this to the Stable milestone Mar 17, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment