2 * "$Id: sysman.c 7928 2008-09-10 22:14:22Z mike $"
4 * System management definitions for the Common UNIX Printing System (CUPS).
6 * Copyright 2007-2009 by Apple Inc.
7 * Copyright 2006 by Easy Software Products.
9 * These coded instructions, statements, and computer programs are the
10 * property of Apple Inc. and are protected by Federal copyright
11 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
12 * which should have been included with this file. If this file is
13 * file is missing or damaged, see the license at "http://www.cups.org/".
17 * cupsdCleanDirty() - Write dirty config and state files.
18 * cupsdMarkDirty() - Mark config or state files as needing a
20 * cupsdSetBusyState() - Let the system know when we are busy
22 * cupsdAllowSleep() - Tell the OS it is now OK to sleep.
23 * cupsdStartSystemMonitor() - Start monitoring for system change.
24 * cupsdStopSystemMonitor() - Stop monitoring for system change.
25 * sysEventThreadEntry() - A thread to receive power and computer
26 * name change notifications.
27 * sysEventPowerNotifier() - Handle power notification events.
28 * sysEventConfigurationNotifier() - Computer name changed notification
30 * sysEventTimerNotifier() - Handle delayed event notifications.
31 * sysUpdate() - Update the current system state.
36 * Include necessary headers...
40 #ifdef HAVE_VPROC_TRANSACTION_BEGIN
42 #endif /* HAVE_VPROC_TRANSACTION_BEGIN */
46 * The system management functions cover disk and power management which
47 * are primarily used on portable computers.
49 * Disk management involves delaying the write of certain configuration
50 * and state files to minimize the number of times the disk has to spin
53 * Power management support is currently only implemented on MacOS X, but
54 * essentially we use four functions to let the OS know when it is OK to
55 * put the system to idle sleep, typically when we are not in the middle of
58 * Once put to sleep, we invalidate all remote printers since it is common
59 * to wake up in a new location/on a new wireless network.
64 * 'cupsdCleanDirty()' - Write dirty config and state files.
70 if (DirtyFiles
& CUPSD_DIRTY_PRINTERS
)
71 cupsdSaveAllPrinters();
73 if (DirtyFiles
& CUPSD_DIRTY_CLASSES
)
74 cupsdSaveAllClasses();
76 if (DirtyFiles
& CUPSD_DIRTY_REMOTE
)
77 cupsdSaveRemoteCache();
79 if (DirtyFiles
& CUPSD_DIRTY_PRINTCAP
)
82 if (DirtyFiles
& CUPSD_DIRTY_JOBS
)
84 cupsd_job_t
*job
; /* Current job */
88 for (job
= (cupsd_job_t
*)cupsArrayFirst(Jobs
);
90 job
= (cupsd_job_t
*)cupsArrayNext(Jobs
))
95 if (DirtyFiles
& CUPSD_DIRTY_SUBSCRIPTIONS
)
96 cupsdSaveAllSubscriptions();
98 DirtyFiles
= CUPSD_DIRTY_NONE
;
106 * 'cupsdMarkDirty()' - Mark config or state files as needing a write.
110 cupsdMarkDirty(int what
) /* I - What file(s) are dirty? */
112 if (what
== CUPSD_DIRTY_PRINTCAP
&& !Printcap
)
118 DirtyCleanTime
= time(NULL
) + DirtyCleanInterval
;
125 * 'cupsdSetBusyState()' - Let the system know when we are busy doing something.
129 cupsdSetBusyState(void)
131 int newbusy
; /* New busy state */
132 static int busy
= 0; /* Current busy state */
133 static const char * const busy_text
[] =
134 { /* Text for busy states */
138 "Printing jobs and dirty files",
140 "Active clients and dirty files",
141 "Active clients and printing jobs",
142 "Active clients, printing jobs, and dirty files"
144 #ifdef HAVE_VPROC_TRANSACTION_BEGIN
145 static vproc_transaction_t vtran
= 0; /* Current busy transaction */
146 #endif /* HAVE_VPROC_TRANSACTION_BEGIN */
149 newbusy
= (DirtyCleanTime
? 1 : 0) |
150 (cupsArrayCount(PrintingJobs
) ? 2 : 0) |
151 (cupsArrayCount(ActiveClients
) ? 4 : 0);
157 #ifdef HAVE_VPROC_TRANSACTION_BEGIN
159 vtran
= vproc_transaction_begin(NULL
);
160 else if (!busy
&& vtran
)
162 vproc_transaction_end(NULL
, vtran
);
165 #endif /* HAVE_VPROC_TRANSACTION_BEGIN */
167 cupsdLogMessage(CUPSD_LOG_DEBUG
, "cupsdSetBusyState: %s", busy_text
[busy
]);
174 * This is the Apple-specific system event code. It works by creating
175 * a worker thread that waits for events from the OS and relays them
176 * to the main thread via a traditional pipe.
180 * Include MacOS-specific headers...
183 # include <IOKit/IOKitLib.h>
184 # include <IOKit/IOMessage.h>
185 # include <IOKit/pwr_mgt/IOPMLib.h>
186 # include <SystemConfiguration/SystemConfiguration.h>
187 # include <pthread.h>
194 # define SYSEVENT_CANSLEEP 0x1 /* Decide whether to allow sleep or not */
195 # define SYSEVENT_WILLSLEEP 0x2 /* Computer will go to sleep */
196 # define SYSEVENT_WOKE 0x4 /* Computer woke from sleep */
197 # define SYSEVENT_NETCHANGED 0x8 /* Network changed */
198 # define SYSEVENT_NAMECHANGED 0x10 /* Computer name changed */
205 typedef struct cupsd_sysevent_s
/*** System event data ****/
207 unsigned char event
; /* Event bit field */
208 io_connect_t powerKernelPort
; /* Power context data */
209 long powerNotificationID
; /* Power event data */
213 typedef struct cupsd_thread_data_s
/*** Thread context data ****/
215 cupsd_sysevent_t sysevent
; /* System event */
216 CFRunLoopTimerRef timerRef
; /* Timer to delay some change *
218 } cupsd_thread_data_t
;
225 static pthread_t SysEventThread
= NULL
;
226 /* Thread to host a runloop */
227 static pthread_mutex_t SysEventThreadMutex
= { 0 };
228 /* Coordinates access to shared gloabals */
229 static pthread_cond_t SysEventThreadCond
= { 0 };
230 /* Thread initialization complete condition */
231 static CFRunLoopRef SysEventRunloop
= NULL
;
232 /* The runloop. Access must be protected! */
233 static CFStringRef ComputerNameKey
= NULL
,
234 /* Computer name key */
235 BTMMKey
= NULL
, /* Back to My Mac key */
236 NetworkGlobalKeyIPv4
= NULL
,
237 /* Network global IPv4 key */
238 NetworkGlobalKeyIPv6
= NULL
,
239 /* Network global IPv6 key */
240 NetworkGlobalKeyDNS
= NULL
,
241 /* Network global DNS key */
244 NetworkInterfaceKeyIPv4
= NULL
,
245 /* Netowrk interface key */
246 NetworkInterfaceKeyIPv6
= NULL
;
247 /* Netowrk interface key */
248 static cupsd_sysevent_t LastSysEvent
; /* Last system event (for delayed sleep) */
255 static void *sysEventThreadEntry(void);
256 static void sysEventPowerNotifier(void *context
, io_service_t service
,
257 natural_t messageType
,
258 void *messageArgument
);
259 static void sysEventConfigurationNotifier(SCDynamicStoreRef store
,
260 CFArrayRef changedKeys
,
262 static void sysEventTimerNotifier(CFRunLoopTimerRef timer
, void *context
);
263 static void sysUpdate(void);
267 * 'cupsdAllowSleep()' - Tell the OS it is now OK to sleep.
271 cupsdAllowSleep(void)
275 IOAllowPowerChange(LastSysEvent
.powerKernelPort
,
276 LastSysEvent
.powerNotificationID
);
281 * 'cupsdStartSystemMonitor()' - Start monitoring for system change.
285 cupsdStartSystemMonitor(void)
287 int flags
; /* fcntl flags on pipe */
290 if (cupsdOpenPipe(SysEventPipes
))
292 cupsdLogMessage(CUPSD_LOG_ERROR
, "System event monitor pipe() failed - %s!",
297 cupsdAddSelect(SysEventPipes
[0], (cupsd_selfunc_t
)sysUpdate
, NULL
, NULL
);
300 * Set non-blocking mode on the descriptor we will be receiving notification
304 flags
= fcntl(SysEventPipes
[0], F_GETFL
, 0);
305 fcntl(SysEventPipes
[0], F_SETFL
, flags
| O_NONBLOCK
);
308 * Start the thread that runs the runloop...
311 pthread_mutex_init(&SysEventThreadMutex
, NULL
);
312 pthread_cond_init(&SysEventThreadCond
, NULL
);
313 pthread_create(&SysEventThread
, NULL
, (void *(*)())sysEventThreadEntry
, NULL
);
318 * 'cupsdStopSystemMonitor()' - Stop monitoring for system change.
322 cupsdStopSystemMonitor(void)
324 CFRunLoopRef rl
; /* The event handler runloop */
330 * Make sure the thread has completed it's initialization and
331 * stored it's runloop reference in the shared global.
334 pthread_mutex_lock(&SysEventThreadMutex
);
336 if (!SysEventRunloop
)
337 pthread_cond_wait(&SysEventThreadCond
, &SysEventThreadMutex
);
339 rl
= SysEventRunloop
;
340 SysEventRunloop
= NULL
;
342 pthread_mutex_unlock(&SysEventThreadMutex
);
347 pthread_join(SysEventThread
, NULL
);
348 pthread_mutex_destroy(&SysEventThreadMutex
);
349 pthread_cond_destroy(&SysEventThreadCond
);
352 if (SysEventPipes
[0] >= 0)
354 cupsdRemoveSelect(SysEventPipes
[0]);
355 cupsdClosePipe(SysEventPipes
);
361 * 'sysEventThreadEntry()' - A thread to receive power and computer name
362 * change notifications.
365 static void * /* O - Return status/value */
366 sysEventThreadEntry(void)
368 io_object_t powerNotifierObj
;
369 /* Power notifier object */
370 IONotificationPortRef powerNotifierPort
;
371 /* Power notifier port */
372 SCDynamicStoreRef store
= NULL
;/* System Config dynamic store */
373 CFRunLoopSourceRef powerRLS
= NULL
,/* Power runloop source */
374 storeRLS
= NULL
;/* System Config runloop source */
375 CFStringRef key
[6], /* System Config keys */
376 pattern
[2]; /* System Config patterns */
377 CFArrayRef keys
= NULL
, /* System Config key array*/
378 patterns
= NULL
;/* System Config pattern array */
379 SCDynamicStoreContext storeContext
; /* Dynamic store context */
380 CFRunLoopTimerContext timerContext
; /* Timer context */
381 cupsd_thread_data_t threadData
; /* Thread context data for the *
382 * runloop notifiers */
386 * Register for power state change notifications
389 bzero(&threadData
, sizeof(threadData
));
391 threadData
.sysevent
.powerKernelPort
=
392 IORegisterForSystemPower(&threadData
, &powerNotifierPort
,
393 sysEventPowerNotifier
, &powerNotifierObj
);
395 if (threadData
.sysevent
.powerKernelPort
)
397 powerRLS
= IONotificationPortGetRunLoopSource(powerNotifierPort
);
398 CFRunLoopAddSource(CFRunLoopGetCurrent(), powerRLS
, kCFRunLoopDefaultMode
);
401 DEBUG_puts("sysEventThreadEntry: error registering for system power "
405 * Register for system configuration change notifications
408 bzero(&storeContext
, sizeof(storeContext
));
409 storeContext
.info
= &threadData
;
411 store
= SCDynamicStoreCreate(kCFAllocatorDefault
, CFSTR("cupsd"),
412 sysEventConfigurationNotifier
, &storeContext
);
414 if (!ComputerNameKey
)
415 ComputerNameKey
= SCDynamicStoreKeyCreateComputerName(kCFAllocatorDefault
);
418 BTMMKey
= SCDynamicStoreKeyCreate(kCFAllocatorDefault
,
419 CFSTR("Setup:/Network/BackToMyMac"));
421 if (!NetworkGlobalKeyIPv4
)
422 NetworkGlobalKeyIPv4
=
423 SCDynamicStoreKeyCreateNetworkGlobalEntity(kCFAllocatorDefault
,
424 kSCDynamicStoreDomainState
,
427 if (!NetworkGlobalKeyIPv6
)
428 NetworkGlobalKeyIPv6
=
429 SCDynamicStoreKeyCreateNetworkGlobalEntity(kCFAllocatorDefault
,
430 kSCDynamicStoreDomainState
,
433 if (!NetworkGlobalKeyDNS
)
434 NetworkGlobalKeyDNS
=
435 SCDynamicStoreKeyCreateNetworkGlobalEntity(kCFAllocatorDefault
,
436 kSCDynamicStoreDomainState
,
440 HostNamesKey
= SCDynamicStoreKeyCreateHostNames(kCFAllocatorDefault
);
442 if (!NetworkInterfaceKeyIPv4
)
443 NetworkInterfaceKeyIPv4
=
444 SCDynamicStoreKeyCreateNetworkInterfaceEntity(kCFAllocatorDefault
,
445 kSCDynamicStoreDomainState
,
449 if (!NetworkInterfaceKeyIPv6
)
450 NetworkInterfaceKeyIPv6
=
451 SCDynamicStoreKeyCreateNetworkInterfaceEntity(kCFAllocatorDefault
,
452 kSCDynamicStoreDomainState
,
456 if (store
&& ComputerNameKey
&& HostNamesKey
&&
457 NetworkGlobalKeyIPv4
&& NetworkGlobalKeyIPv6
&& NetworkGlobalKeyDNS
&&
458 NetworkInterfaceKeyIPv4
&& NetworkInterfaceKeyIPv6
)
460 key
[0] = ComputerNameKey
;
462 key
[2] = NetworkGlobalKeyIPv4
;
463 key
[3] = NetworkGlobalKeyIPv6
;
464 key
[4] = NetworkGlobalKeyDNS
;
465 key
[5] = HostNamesKey
;
467 pattern
[0] = NetworkInterfaceKeyIPv4
;
468 pattern
[1] = NetworkInterfaceKeyIPv6
;
470 keys
= CFArrayCreate(kCFAllocatorDefault
, (const void **)key
,
471 sizeof(key
) / sizeof(key
[0]),
472 &kCFTypeArrayCallBacks
);
474 patterns
= CFArrayCreate(kCFAllocatorDefault
, (const void **)pattern
,
475 sizeof(pattern
) / sizeof(pattern
[0]),
476 &kCFTypeArrayCallBacks
);
478 if (keys
&& patterns
&&
479 SCDynamicStoreSetNotificationKeys(store
, keys
, patterns
))
481 if ((storeRLS
= SCDynamicStoreCreateRunLoopSource(kCFAllocatorDefault
,
484 CFRunLoopAddSource(CFRunLoopGetCurrent(), storeRLS
,
485 kCFRunLoopDefaultMode
);
488 DEBUG_printf(("sysEventThreadEntry: SCDynamicStoreCreateRunLoopSource "
489 "failed: %s\n", SCErrorString(SCError())));
492 DEBUG_printf(("sysEventThreadEntry: SCDynamicStoreSetNotificationKeys "
493 "failed: %s\n", SCErrorString(SCError())));
496 DEBUG_printf(("sysEventThreadEntry: SCDynamicStoreCreate failed: %s\n",
497 SCErrorString(SCError())));
506 * Set up a timer to delay the wake change notifications.
508 * The initial time is set a decade or so into the future, we'll adjust
512 bzero(&timerContext
, sizeof(timerContext
));
513 timerContext
.info
= &threadData
;
515 threadData
.timerRef
=
516 CFRunLoopTimerCreate(kCFAllocatorDefault
,
517 CFAbsoluteTimeGetCurrent() + (86400L * 365L * 10L),
518 86400L * 365L * 10L, 0, 0, sysEventTimerNotifier
,
520 CFRunLoopAddTimer(CFRunLoopGetCurrent(), threadData
.timerRef
,
521 kCFRunLoopDefaultMode
);
524 * Store our runloop in a global so the main thread can use it to stop us.
527 pthread_mutex_lock(&SysEventThreadMutex
);
529 SysEventRunloop
= CFRunLoopGetCurrent();
531 pthread_cond_signal(&SysEventThreadCond
);
532 pthread_mutex_unlock(&SysEventThreadMutex
);
535 * Disappear into the runloop until it's stopped by the main thread.
541 * Clean up before exiting.
544 if (threadData
.timerRef
)
546 CFRunLoopRemoveTimer(CFRunLoopGetCurrent(), threadData
.timerRef
,
547 kCFRunLoopDefaultMode
);
548 CFRelease(threadData
.timerRef
);
551 if (threadData
.sysevent
.powerKernelPort
)
553 CFRunLoopRemoveSource(CFRunLoopGetCurrent(), powerRLS
,
554 kCFRunLoopDefaultMode
);
555 IODeregisterForSystemPower(&powerNotifierObj
);
556 IOServiceClose(threadData
.sysevent
.powerKernelPort
);
557 IONotificationPortDestroy(powerNotifierPort
);
562 CFRunLoopRemoveSource(CFRunLoopGetCurrent(), storeRLS
,
563 kCFRunLoopDefaultMode
);
564 CFRunLoopSourceInvalidate(storeRLS
);
576 * 'sysEventPowerNotifier()' - Handle power notification events.
580 sysEventPowerNotifier(
581 void *context
, /* I - Thread context data */
582 io_service_t service
, /* I - Unused service info */
583 natural_t messageType
, /* I - Type of message */
584 void *messageArgument
) /* I - Message data */
586 int sendit
= 1; /* Send event to main thread? *
587 * (0 = no, 1 = yes, 2 = delayed */
588 cupsd_thread_data_t
*threadData
; /* Thread context data */
591 threadData
= (cupsd_thread_data_t
*)context
;
593 (void)service
; /* anti-compiler-warning-code */
597 case kIOMessageCanSystemPowerOff
:
598 case kIOMessageCanSystemSleep
:
599 threadData
->sysevent
.event
|= SYSEVENT_CANSLEEP
;
602 case kIOMessageSystemWillRestart
:
603 case kIOMessageSystemWillPowerOff
:
604 case kIOMessageSystemWillSleep
:
605 threadData
->sysevent
.event
|= SYSEVENT_WILLSLEEP
;
608 case kIOMessageSystemHasPoweredOn
:
610 * Because powered on is followed by a net-changed event, delay
615 threadData
->sysevent
.event
|= SYSEVENT_WOKE
;
618 case kIOMessageSystemWillNotPowerOff
:
619 case kIOMessageSystemWillNotSleep
:
620 # ifdef kIOMessageSystemWillPowerOn
621 case kIOMessageSystemWillPowerOn
:
622 # endif /* kIOMessageSystemWillPowerOn */
629 IOAllowPowerChange(threadData
->sysevent
.powerKernelPort
,
630 (long)messageArgument
);
633 threadData
->sysevent
.powerNotificationID
= (long)messageArgument
;
638 * Send the event to the main thread now.
641 write(SysEventPipes
[1], &threadData
->sysevent
,
642 sizeof(threadData
->sysevent
));
643 threadData
->sysevent
.event
= 0;
648 * Send the event to the main thread after 1 to 2 seconds.
651 CFRunLoopTimerSetNextFireDate(threadData
->timerRef
,
652 CFAbsoluteTimeGetCurrent() + 2);
659 * 'sysEventConfigurationNotifier()' - Network configuration change notification
664 sysEventConfigurationNotifier(
665 SCDynamicStoreRef store
, /* I - System data (unused) */
666 CFArrayRef changedKeys
, /* I - Changed data */
667 void *context
) /* I - Thread context data */
669 cupsd_thread_data_t
*threadData
; /* Thread context data */
672 threadData
= (cupsd_thread_data_t
*)context
;
674 (void)store
; /* anti-compiler-warning-code */
676 CFRange range
= CFRangeMake(0, CFArrayGetCount(changedKeys
));
678 if (CFArrayContainsValue(changedKeys
, range
, ComputerNameKey
) ||
679 CFArrayContainsValue(changedKeys
, range
, BTMMKey
))
680 threadData
->sysevent
.event
|= SYSEVENT_NAMECHANGED
;
683 threadData
->sysevent
.event
|= SYSEVENT_NETCHANGED
;
686 * Indicate the network interface list needs updating...
693 * Because we registered for several different kinds of change notifications
694 * this callback usually gets called several times in a row. We use a timer to
695 * de-bounce these so we only end up generating one event for the main thread.
698 CFRunLoopTimerSetNextFireDate(threadData
->timerRef
,
699 CFAbsoluteTimeGetCurrent() + 5);
704 * 'sysEventTimerNotifier()' - Handle delayed event notifications.
708 sysEventTimerNotifier(
709 CFRunLoopTimerRef timer
, /* I - Timer information */
710 void *context
) /* I - Thread context data */
712 cupsd_thread_data_t
*threadData
; /* Thread context data */
715 threadData
= (cupsd_thread_data_t
*)context
;
718 * If an event is still pending send it to the main thread.
721 if (threadData
->sysevent
.event
)
723 write(SysEventPipes
[1], &threadData
->sysevent
,
724 sizeof(threadData
->sysevent
));
725 threadData
->sysevent
.event
= 0;
731 * 'sysUpdate()' - Update the current system state.
737 int i
; /* Looping var */
738 cupsd_sysevent_t sysevent
; /* The system event */
739 cupsd_printer_t
*p
; /* Printer information */
743 * Drain the event pipe...
746 while (read((int)SysEventPipes
[0], &sysevent
, sizeof(sysevent
))
749 if (sysevent
.event
& SYSEVENT_CANSLEEP
)
752 * If there are active printers that don't have the connecting-to-device
753 * printer-state-reason then cancel the sleep request (i.e. this reason
754 * indicates a job that is not yet connected to the printer)...
757 for (p
= (cupsd_printer_t
*)cupsArrayFirst(Printers
);
759 p
= (cupsd_printer_t
*)cupsArrayNext(Printers
))
763 for (i
= 0; i
< p
->num_reasons
; i
++)
764 if (!strcmp(p
->reasons
[i
], "connecting-to-device"))
767 if (!p
->num_reasons
|| i
>= p
->num_reasons
)
774 cupsdLogMessage(CUPSD_LOG_INFO
,
775 "System sleep canceled because printer %s is active",
777 IOCancelPowerChange(sysevent
.powerKernelPort
,
778 sysevent
.powerNotificationID
);
782 cupsdLogMessage(CUPSD_LOG_DEBUG
, "System wants to sleep");
783 IOAllowPowerChange(sysevent
.powerKernelPort
,
784 sysevent
.powerNotificationID
);
788 if (sysevent
.event
& SYSEVENT_WILLSLEEP
)
790 cupsdLogMessage(CUPSD_LOG_DEBUG
, "System going to sleep");
794 for (p
= (cupsd_printer_t
*)cupsArrayFirst(Printers
);
796 p
= (cupsd_printer_t
*)cupsArrayNext(Printers
))
798 if (p
->type
& CUPS_PRINTER_DISCOVERED
)
800 cupsdLogMessage(CUPSD_LOG_DEBUG
,
801 "Deleting remote destination \"%s\"", p
->name
);
802 cupsArraySave(Printers
);
803 cupsdDeletePrinter(p
, 0);
804 cupsArrayRestore(Printers
);
808 cupsdLogMessage(CUPSD_LOG_DEBUG
,
809 "Deregistering local printer \"%s\"", p
->name
);
810 cupsdDeregisterPrinter(p
, 0);
817 * If we have no printing jobs, allow the power change immediately.
818 * Otherwise set the SleepJobs time to 15 seconds in the future when
819 * we'll take more drastic measures...
822 if (cupsArrayCount(PrintingJobs
) == 0)
823 IOAllowPowerChange(sysevent
.powerKernelPort
,
824 sysevent
.powerNotificationID
);
827 LastSysEvent
= sysevent
;
828 SleepJobs
= time(NULL
) + 15;
832 if (sysevent
.event
& SYSEVENT_WOKE
)
834 cupsdLogMessage(CUPSD_LOG_DEBUG
, "System woke from sleep");
835 IOAllowPowerChange(sysevent
.powerKernelPort
,
836 sysevent
.powerNotificationID
);
841 if (sysevent
.event
& SYSEVENT_NETCHANGED
)
845 cupsdLogMessage(CUPSD_LOG_DEBUG
,
846 "System network configuration changed");
849 * Resetting browse_time before calling cupsdSendBrowseList causes
850 * browse packets to be sent for local shared printers.
853 for (p
= (cupsd_printer_t
*)cupsArrayFirst(Printers
);
855 p
= (cupsd_printer_t
*)cupsArrayNext(Printers
))
858 cupsdSendBrowseList();
859 cupsdRestartPolling();
862 cupsdLogMessage(CUPSD_LOG_DEBUG
,
863 "System network configuration changed; "
864 "ignored while sleeping");
867 if (sysevent
.event
& SYSEVENT_NAMECHANGED
)
871 cupsdLogMessage(CUPSD_LOG_DEBUG
,
872 "Computer name or BTMM domains changed");
875 * De-register the individual printers...
878 for (p
= (cupsd_printer_t
*)cupsArrayFirst(Printers
);
880 p
= (cupsd_printer_t
*)cupsArrayNext(Printers
))
881 cupsdDeregisterPrinter(p
, 1);
884 * Update the computer name and BTMM domain list...
887 cupsdUpdateDNSSDName();
890 * Now re-register them...
893 for (p
= (cupsd_printer_t
*)cupsArrayFirst(Printers
);
895 p
= (cupsd_printer_t
*)cupsArrayNext(Printers
))
898 cupsdRegisterPrinter(p
);
902 cupsdLogMessage(CUPSD_LOG_DEBUG
,
903 "Computer name or BTMM domains changed; ignored while "
908 #endif /* __APPLE__ */
912 * End of "$Id: sysman.c 7928 2008-09-10 22:14:22Z mike $".