static void SignalHandler1(int sigraised) { DEBUG_LOG("\nInterrupted\n"); // special shutdown sequence // - no longer tracking MouseCount, so set to zero // - and send special -1 MouseCount so LED can be forced off SendMouseCount(0); SendMouseCount(-1); // clean up here if (g_AddedIter) { IOObjectRelease(g_AddedIter); g_AddedIter = 0; } IONotificationPortDestroy(g_NotifyPort); if (g_ioservice) { IOObjectRelease(g_ioservice); g_ioservice = 0; } // exit(0) should not be called from a signal handler. Use _exit(0) instead _exit(0); }
void CCocoaPowerSyscall::DeleteOSPowerCallBacks(void) { #if !defined(TARGET_DARWIN_IOS) CCocoaAutoPool autopool; // we no longer want sleep/wake notifications // remove the sleep notification port from the application runloop CFRunLoopRemoveSource( CFRunLoopGetCurrent(), IONotificationPortGetRunLoopSource(m_notify_port), kCFRunLoopDefaultMode ); // deregister for system sleep notifications IODeregisterForSystemPower(&m_notifier_object); // IORegisterForSystemPower implicitly opens the Root Power Domain IOService // so we close it here IOServiceClose(m_root_port); // destroy the notification port allocated by IORegisterForSystemPower IONotificationPortDestroy(m_notify_port); // we no longer want power source change notifications if (m_HasBattery) { if (m_power_source) { CFRunLoopRemoveSource( CFRunLoopGetCurrent(), m_power_source, kCFRunLoopDefaultMode ); CFRelease(m_power_source); } } #endif }
/* Cleanup of the open ports */ void PortsCleanup() { CFRunLoopRemoveSource(CFRunLoopGetCurrent(), IONotificationPortGetRunLoopSource(notifyPortRef), kCFRunLoopCommonModes); /* Remove the notification port from the runloop */ IODeregisterForSystemPower(¬ifierObject); /* Deregister from power notifications */ IOServiceClose(root_power_port); /* Close the Root Power Domain IOService port */ IONotificationPortDestroy(notifyPortRef); /* Destroy the notification port */ }
void* RunLoopThread(void* args) { unsigned i; InitUSB(); currentRunLoop = CFRunLoopGetCurrent(); CFRunLoopTimerContext context = {0, NULL, NULL, NULL, NULL}; CFRunLoopTimerRef timer = CFRunLoopTimerCreate(kCFAllocatorDefault, 0.1, 0.1, 0, 0, &onTimerFired, &context); CFRunLoopAddTimer(currentRunLoop, timer, kCFRunLoopCommonModes); // Signal the parent that we are running adb_mutex_lock(&start_lock); adb_cond_signal(&start_cond); adb_mutex_unlock(&start_lock); CFRunLoopRun(); currentRunLoop = 0; for (i = 0; i < vendorIdCount; i++) { IOObjectRelease(notificationIterators[i]); } IONotificationPortDestroy(notificationPort); usb_cleanup(); DBG("RunLoopThread done\n"); return NULL; }
void mac_sleep_stop() { if (root_port) { // remove the sleep notification port from the application runloop CFRunLoopRemoveSource(CFRunLoopGetCurrent(), IONotificationPortGetRunLoopSource(notifyPortRef), kCFRunLoopCommonModes); // deregister for system sleep notifications IODeregisterForSystemPower(¬ifierObject); // IORegisterForSystemPower implicitly opens the Root Power Domain IOService // so we close it here IOServiceClose(root_port); // destroy the notification port allocated by IORegisterForSystemPower IONotificationPortDestroy(notifyPortRef); // reset object members root_port = 0; notifyPortRef = NULL; notifierObject = 0; } }
static void CleanupIOKit() { // if(ioRunLoopSource != NULL) // CFRunLoopRemoveSource(CFRunLoopGetCurrent(), ioRunLoopSource, // kCFRunLoopDefaultMode); if(ioKitNotificationPort != NULL) IONotificationPortDestroy(ioKitNotificationPort); }
void IOKitEventPublisher::stop() { if (run_loop_ == nullptr) { // If there is no run loop then the publisher thread has not started. return; } // Stop the run loop. WriteLock lock(mutex_); CFRunLoopStop(run_loop_); // Stop the run loop before operating on containers. // Destroy the IOPort. if (port_ != nullptr) { auto source = IONotificationPortGetRunLoopSource(port_); if (CFRunLoopContainsSource(run_loop_, source, kCFRunLoopDefaultMode)) { CFRunLoopRemoveSource(run_loop_, source, kCFRunLoopDefaultMode); } // And destroy the port. IONotificationPortDestroy(port_); port_ = nullptr; } // Clear all devices and their notifications. for (const auto& device : devices_) { IOObjectRelease(device->notification); } devices_.clear(); }
void SignalHandler(int sigraised) { printf("\nInterrupted\n"); // Clean up here IONotificationPortDestroy(gNotifyPort); if (gRawAddedIter) { IOObjectRelease(gRawAddedIter); gRawAddedIter = 0; } if (gRawRemovedIter) { IOObjectRelease(gRawRemovedIter); gRawRemovedIter = 0; } if (gBulkTestAddedIter) { IOObjectRelease(gBulkTestAddedIter); gBulkTestAddedIter = 0; } if (gBulkTestRemovedIter) { IOObjectRelease(gBulkTestRemovedIter); gBulkTestRemovedIter = 0; } // exit(0) should not be called from a signal handler. Use _exit(0) instead // _exit(0); }
SymbianDeviceManager::~SymbianDeviceManager() { #ifdef Q_OS_MACX if (d && d->m_deviceListChangedNotification) IONotificationPortDestroy(d->m_deviceListChangedNotification); #endif delete d; }
JNIEXPORT void JNICALL Java_bits_hidpunk_osx_CFNotificationSource_destroyPort (JNIEnv* env, jclass clazz, jlong portPtr) { IONotificationPortRef port = (IONotificationPortRef)portPtr; if(port) { IONotificationPortDestroy(port); } }
QextSerialEnumerator::~QextSerialEnumerator( ) { #ifdef Q_OS_MAC IONotificationPortDestroy( notificationPortRef ); #endif #if (defined Q_OS_WIN) && (defined QT_GUI_LIB) if( notificationWidget ) delete notificationWidget; #endif }
/*! Deregisters the daemon with the kernel to no longer receive power events. */ void iSCSIDDeregisterForPowerEvents() { CFRunLoopRemoveSource(CFRunLoopGetCurrent(), IONotificationPortGetRunLoopSource(powerNotifyPortRef), kCFRunLoopDefaultMode); IODeregisterForSystemPower(&powerNotifier); IOServiceClose(powerPlaneRoot); IONotificationPortDestroy(powerNotifyPortRef); }
/* Function to perform any system-specific joystick related cleanup */ void SDL_SYS_JoystickQuit(void) { while (NULL != gpDeviceList) gpDeviceList = HIDDisposeDevice(&gpDeviceList); if ( notificationPort ) { IONotificationPortDestroy( notificationPort ); notificationPort = 0; } }
io_connect_t IORegisterForSystemPower ( void * refcon, IONotificationPortRef * thePortRef, IOServiceInterestCallback callback, io_object_t * root_notifier ) { io_connect_t fb = IO_OBJECT_NULL; IONotificationPortRef notify = NULL; kern_return_t kr; io_service_t obj = IO_OBJECT_NULL; *root_notifier = IO_OBJECT_NULL; notify = IONotificationPortCreate(MACH_PORT_NULL); obj = IORegistryEntryFromPath( IO_OBJECT_NULL, kIOPowerPlane ":/IOPowerConnection/IOPMrootDomain"); if( obj == IO_OBJECT_NULL) goto failure_exit; kr = IOServiceOpen( obj,mach_task_self(), 0, &fb); if ( (kr != kIOReturnSuccess) || (fb == IO_OBJECT_NULL) ) { goto failure_exit; } kr = IOServiceAddInterestNotification( notify,obj,kIOAppPowerStateInterest, callback,refcon,root_notifier); IOObjectRelease(obj); if ( kr == KERN_SUCCESS ) { // Successful exit case *thePortRef = notify; return fb; } failure_exit: if ( obj != IO_OBJECT_NULL) { IOObjectRelease(obj); } if ( notify != NULL) { IONotificationPortDestroy(notify); } if ( fb != IO_OBJECT_NULL) { IOServiceClose(fb); } if ( *root_notifier != IO_OBJECT_NULL) { IOObjectRelease(*root_notifier); } return IO_OBJECT_NULL; }
QextSerialEnumerator::~QextSerialEnumerator( ) { #ifdef Q_OS_MAC IONotificationPortDestroy( notificationPortRef ); #elif (defined Q_OS_WIN) if( notificationHandle ) UnregisterDeviceNotification( notificationHandle ); #ifdef QT_GUI_LIB if( notificationWidget ) delete notificationWidget; #endif #endif }
//--------------------------------------------------------------------------- // SignalHandler //--------------------------------------------------------------------------- void SignalHandler(int sigraised) { syslog(LOG_INFO, "upsd: exiting SIGINT\n"); // Clean up here IONotificationPortDestroy(gNotifyPort); if (gAddedIter) { IOObjectRelease(gAddedIter); gAddedIter = 0; } exit(0); }
void SystemEventsManager::stopLoop(bool forceStop) { if (systemEventLoopRunning && (forceStop || allEventsDisabled())) { CFRunLoopRemoveSource(CFRunLoopGetCurrent(), IONotificationPortGetRunLoopSource(notifyPortRef), kCFRunLoopCommonModes); IODeregisterForSystemPower(¬ifierObject); IOServiceClose(rootPort); IONotificationPortDestroy(notifyPortRef); CFRunLoopStop(CFRunLoopGetCurrent()); systemEventLoopRunning = false; } }
void HIDDevice::HIDShutdown() { HIDManager->DevManager->pThread->RemoveTicksNotifier(this); if (Device != NULL) // Device may already have been closed if unplugged. { closeDevice(false); } IOObjectRelease(RepluggedNotification); IONotificationPortDestroy(RepluggedNotificationPort); LogText("OVR::OSX::HIDDevice - HIDShutdown '%s'\n", DevDesc.Path.ToCStr()); }
HostPowerServiceDarwin::~HostPowerServiceDarwin() { /* Jump out of the run loop. */ CFRunLoopStop(mRunLoop); /* Remove the sleep notification port from the application runloop. */ CFRunLoopRemoveSource(CFRunLoopGetCurrent(), IONotificationPortGetRunLoopSource(mNotifyPort), kCFRunLoopCommonModes); /* Deregister for system sleep notifications. */ IODeregisterForSystemPower(&mNotifierObject); /* IORegisterForSystemPower implicitly opens the Root Power Domain * IOService so we close it here. */ IOServiceClose(mRootPort); /* Destroy the notification port allocated by IORegisterForSystemPower */ IONotificationPortDestroy(mNotifyPort); }
InputHandler_MacOSX_HID::~InputHandler_MacOSX_HID() { FOREACH( HIDDevice *, m_vDevices, i ) delete *i; if( PREFSMAN->m_bThreadedInput ) { CFRunLoopSourceSignal( m_SourceRef ); CFRunLoopWakeUp( m_LoopRef ); m_InputThread.Wait(); CFRelease( m_SourceRef ); CFRelease( m_LoopRef ); LOG->Trace( "Input handler thread shut down." ); } FOREACH( io_iterator_t, m_vIters, i ) IOObjectRelease( *i ); IONotificationPortDestroy( m_NotifyPort ); }
void* RunLoopThread(void* unused) { InitUSB(); currentRunLoop = CFRunLoopGetCurrent(); // Signal the parent that we are running adb_mutex_lock(&start_lock); adb_cond_signal(&start_cond); adb_mutex_unlock(&start_lock); CFRunLoopRun(); currentRunLoop = 0; IOObjectRelease(notificationIterator); IONotificationPortDestroy(notificationPort); DBG("RunLoopThread done\n"); return NULL; }
TorcUSBPrivOSX::~TorcUSBPrivOSX() { // free outstanding notifications LOG(VB_GENERAL, LOG_DEBUG, QString("%1 outstanding notifications").arg(m_notifications.size())); { QMutexLocker locker(m_notificationsLock); QMap<io_service_t,QPair<io_object_t,QString> >::iterator it = m_notifications.begin(); for ( ; it != m_notifications.end(); ++it) { QPair<io_object_t,QString> pair = it.value(); IOObjectRelease(pair.first); } m_notifications.clear(); } // release source - for some reason this is unsafe when running outside of the main runloop. if (m_usbRef && gAdminRunLoop && gAdminRunLoop != CFRunLoopGetMain()) { CFRunLoopRemoveSource(gAdminRunLoop, m_usbRef, kCFRunLoopDefaultMode); CFRelease(m_usbRef); m_usbRef = NULL; } // release notify port if (m_usbNotifyPort) { IONotificationPortDestroy(m_usbNotifyPort); m_usbNotifyPort = NULL; } // release iterator if (m_iterator) IOObjectRelease(m_iterator); m_iterator = 0; // delete lock delete m_notificationsLock; m_notificationsLock = NULL; }
CFStringRef copy_wifi_mac_address() { CFStringRef wifimac = NULL; IONotificationPortRef notify_port = 0; io_iterator_t iterator = 0; wifimac = lookup_mac_address("sdio"); if (wifimac != NULL) return wifimac; wifimac = lookup_mac_address("wlan"); if (wifimac != NULL) return wifimac; notify_port = IONotificationPortCreate(kIOMasterPortDefault); CFRunLoopSourceRef runLoopSource = IONotificationPortGetRunLoopSource(notify_port); CFRunLoopAddSource(CFRunLoopGetCurrent(), runLoopSource, kCFRunLoopDefaultMode); if (!IOServiceAddMatchingNotification( notify_port, kIOMatchedNotification, IOServiceMatching("IONetworkController"), (IOServiceMatchingCallback) search_wifi_mac_callback, &wifimac, &iterator )) { search_wifi_mac_callback((void**)&wifimac, iterator); while( wifimac == NULL) { if( CFRunLoopRunInMode(kCFRunLoopDefaultMode,0, TRUE) != kCFRunLoopRunHandledSource) { printf("giving up on wifi mac address\n"); break; } } } IONotificationPortDestroy(notify_port); return wifimac; }
void* RunLoopThread(void* args) { unsigned i; InitUSB(); currentRunLoop = CFRunLoopGetCurrent(); CFRunLoopTimerContext context = {0, NULL, NULL, NULL, NULL}; CFRunLoopTimerRef timer = CFRunLoopTimerCreate(kCFAllocatorDefault, 0.1, 0.1, 0, 0, &onTimerFired, &context); CFRunLoopAddTimer(currentRunLoop, timer, kCFRunLoopCommonModes); // Signal the parent that we are running adb_mutex_lock(&start_lock); adb_cond_signal(&start_cond); adb_mutex_unlock(&start_lock); set_device_loop_state(kDeviceLoopRunning); CFRunLoopRun(); set_device_loop_state(kDeviceLoopDead); currentRunLoop = 0; for (i = 0; i < vendorIdCount; i++) { IOObjectRelease(notificationIterators[i]); } IONotificationPortDestroy(notificationPort); if (notificationIterators != NULL) { D("Before notification free\n"); free(notificationIterators); notificationIterators = NULL; } D("After all\n"); initialized = 0; DBG("RunLoopThread done\n"); return NULL; }
void* RunLoopThread(void* unused) { unsigned i; InitUSB(); currentRunLoop = CFRunLoopGetCurrent(); // Signal the parent that we are running sdb_mutex_lock(&start_lock); sdb_cond_signal(&start_cond); sdb_mutex_unlock(&start_lock); CFRunLoopRun(); currentRunLoop = 0; for (i = 0; i < vendorIdCount; i++) { IOObjectRelease(notificationIterators[i]); } IONotificationPortDestroy(notificationPort); DBG("RunLoopThread done\n"); return NULL; }
static void iokit_poll_notifications(void *opaque) { int phase = 0; Semaphore *handshake = opaque; IONotificationPortRef notification_port; io_object_t notifier; io_connect_t root_port; CFRunLoopSourceRef notification_run_loop_source; log_debug("Started notification poll thread"); // need to register this PThread with the Objective-C garbage collector, // because CoreFoundation uses Objective-C #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 objc_registerThreadWithCollector(); #endif // register for system sleep/wake notifications root_port = IORegisterForSystemPower(&root_port, ¬ification_port, iokit_handle_notifications, ¬ifier); if (root_port == MACH_PORT_NULL) { log_error("Could not register for root power domain"); goto cleanup; } phase = 1; // get notification run loop source notification_run_loop_source = IONotificationPortGetRunLoopSource(notification_port); if (notification_run_loop_source == NULL) { log_error("Could not get notification run loop source"); goto cleanup; } CFRunLoopAddSource(CFRunLoopGetCurrent(), notification_run_loop_source, kCFRunLoopDefaultMode); phase = 2; // start loop _run_loop = (CFRunLoopRef)CFRetain(CFRunLoopGetCurrent()); _running = true; semaphore_release(handshake); CFRunLoopRun(); log_debug("Stopped notification poll thread"); cleanup: if (!_running) { // need to release the handshake in all cases, otherwise iokit_init // will block forever in semaphore_acquire semaphore_release(handshake); } switch (phase) { // no breaks, all cases fall through intentionally case 2: CFRunLoopRemoveSource(CFRunLoopGetCurrent(), notification_run_loop_source, kCFRunLoopDefaultMode); case 1: IODeregisterForSystemPower(¬ifier); IOServiceClose(root_port); IONotificationPortDestroy(notification_port); default: break; } _running = false; }
void HPMPrivate::run() { mach_port_t masterPort = 0; IONotificationPortRef notifyPort = 0; io_iterator_t rawAddedIter = 0; io_iterator_t rawRemovedIter = 0; // Create an IOMasterPort for accessing IOKit kern_return_t kr = IOMasterPort(MACH_PORT_NULL, &masterPort); if (kr || !masterPort) { qWarning() << Q_FUNC_INFO << "Unable to create a master I/O Kit port" << (void*) kr; return; } // Create a new dictionary for matching device classes CFMutableDictionaryRef matchingDict = IOServiceMatching(kIOUSBDeviceClassName); if (!matchingDict) { qWarning() << Q_FUNC_INFO << "Unable to create a USB matching dictionary"; mach_port_deallocate(mach_task_self(), masterPort); return; } // Take an extra reference because IOServiceAddMatchingNotification consumes one matchingDict = (CFMutableDictionaryRef) CFRetain(matchingDict); // Store the thread's run loop context loop = CFRunLoopGetCurrent(); // New notification port notifyPort = IONotificationPortCreate(masterPort); CFRunLoopSourceRef runLoopSource = IONotificationPortGetRunLoopSource(notifyPort); CFRunLoopAddSource(loop, runLoopSource, kCFRunLoopDefaultMode); // Listen to device add notifications kr = IOServiceAddMatchingNotification(notifyPort, kIOFirstMatchNotification, matchingDict, onHPMPrivateRawDeviceAdded, (void*) this, &rawAddedIter); if (kr != kIOReturnSuccess) qFatal("Unable to add notification for device additions"); // Iterate over set of matching devices to access already-present devices // and to arm the notification. onHPMPrivateRawDeviceAdded(this, rawAddedIter); // Listen to device removal notifications kr = IOServiceAddMatchingNotification(notifyPort, kIOTerminatedNotification, matchingDict, onHPMPrivateRawDeviceRemoved, (void*) this, &rawRemovedIter); if (kr != kIOReturnSuccess) qFatal("Unable to add notification for device termination"); // Iterate over set of matching devices to release each one and to // arm the notification. onHPMPrivateRawDeviceRemoved(this, rawRemovedIter); // No longer needed mach_port_deallocate(mach_task_self(), masterPort); masterPort = 0; // Start the run loop inside this thread. The thread "stops" here. CFRunLoopRun(); // Destroy the notification port when the thread exits IONotificationPortDestroy(notifyPort); notifyPort = 0; }
static void * /* O - Return status/value */ sysEventThreadEntry(void) { io_object_t powerNotifierObj; /* Power notifier object */ IONotificationPortRef powerNotifierPort; /* Power notifier port */ SCDynamicStoreRef store = NULL;/* System Config dynamic store */ CFRunLoopSourceRef powerRLS = NULL,/* Power runloop source */ storeRLS = NULL;/* System Config runloop source */ CFStringRef key[6], /* 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 */ CFRunLoopTimerContext timerContext; /* Timer context */ cupsd_thread_data_t threadData; /* Thread context data for the * * runloop notifiers */ /* * Register for power state change notifications */ bzero(&threadData, sizeof(threadData)); threadData.sysevent.powerKernelPort = IORegisterForSystemPower(&threadData, &powerNotifierPort, sysEventPowerNotifier, &powerNotifierObj); if (threadData.sysevent.powerKernelPort) { powerRLS = IONotificationPortGetRunLoopSource(powerNotifierPort); CFRunLoopAddSource(CFRunLoopGetCurrent(), powerRLS, kCFRunLoopDefaultMode); } else DEBUG_puts("sysEventThreadEntry: error registering for system power " "notifications"); /* * Register for system configuration change notifications */ bzero(&storeContext, sizeof(storeContext)); storeContext.info = &threadData; store = SCDynamicStoreCreate(kCFAllocatorDefault, CFSTR("cupsd"), sysEventConfigurationNotifier, &storeContext); if (!ComputerNameKey) ComputerNameKey = SCDynamicStoreKeyCreateComputerName(kCFAllocatorDefault); if (!BTMMKey) BTMMKey = SCDynamicStoreKeyCreate(kCFAllocatorDefault, CFSTR("Setup:/Network/BackToMyMac")); if (!NetworkGlobalKeyIPv4) NetworkGlobalKeyIPv4 = SCDynamicStoreKeyCreateNetworkGlobalEntity(kCFAllocatorDefault, kSCDynamicStoreDomainState, kSCEntNetIPv4); if (!NetworkGlobalKeyIPv6) NetworkGlobalKeyIPv6 = SCDynamicStoreKeyCreateNetworkGlobalEntity(kCFAllocatorDefault, kSCDynamicStoreDomainState, kSCEntNetIPv6); if (!NetworkGlobalKeyDNS) NetworkGlobalKeyDNS = SCDynamicStoreKeyCreateNetworkGlobalEntity(kCFAllocatorDefault, kSCDynamicStoreDomainState, kSCEntNetDNS); if (!HostNamesKey) HostNamesKey = SCDynamicStoreKeyCreateHostNames(kCFAllocatorDefault); if (!NetworkInterfaceKeyIPv4) NetworkInterfaceKeyIPv4 = SCDynamicStoreKeyCreateNetworkInterfaceEntity(kCFAllocatorDefault, kSCDynamicStoreDomainState, kSCCompAnyRegex, kSCEntNetIPv4); if (!NetworkInterfaceKeyIPv6) NetworkInterfaceKeyIPv6 = SCDynamicStoreKeyCreateNetworkInterfaceEntity(kCFAllocatorDefault, kSCDynamicStoreDomainState, kSCCompAnyRegex, kSCEntNetIPv6); if (store && ComputerNameKey && HostNamesKey && NetworkGlobalKeyIPv4 && NetworkGlobalKeyIPv6 && NetworkGlobalKeyDNS && NetworkInterfaceKeyIPv4 && NetworkInterfaceKeyIPv6) { key[0] = ComputerNameKey; key[1] = BTMMKey; key[2] = NetworkGlobalKeyIPv4; key[3] = NetworkGlobalKeyIPv6; key[4] = NetworkGlobalKeyDNS; key[5] = HostNamesKey; pattern[0] = NetworkInterfaceKeyIPv4; pattern[1] = NetworkInterfaceKeyIPv6; keys = CFArrayCreate(kCFAllocatorDefault, (const void **)key, sizeof(key) / sizeof(key[0]), &kCFTypeArrayCallBacks); patterns = CFArrayCreate(kCFAllocatorDefault, (const void **)pattern, sizeof(pattern) / sizeof(pattern[0]), &kCFTypeArrayCallBacks); if (keys && patterns && SCDynamicStoreSetNotificationKeys(store, keys, patterns)) { if ((storeRLS = SCDynamicStoreCreateRunLoopSource(kCFAllocatorDefault, store, 0)) != NULL) { CFRunLoopAddSource(CFRunLoopGetCurrent(), storeRLS, kCFRunLoopDefaultMode); } else DEBUG_printf(("sysEventThreadEntry: SCDynamicStoreCreateRunLoopSource " "failed: %s\n", SCErrorString(SCError()))); } else DEBUG_printf(("sysEventThreadEntry: SCDynamicStoreSetNotificationKeys " "failed: %s\n", SCErrorString(SCError()))); } else DEBUG_printf(("sysEventThreadEntry: SCDynamicStoreCreate failed: %s\n", SCErrorString(SCError()))); if (keys) CFRelease(keys); if (patterns) CFRelease(patterns); /* * Set up a timer to delay the wake change notifications. * * The initial time is set a decade or so into the future, we'll adjust * this later. */ bzero(&timerContext, sizeof(timerContext)); timerContext.info = &threadData; threadData.timerRef = CFRunLoopTimerCreate(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent() + (86400L * 365L * 10L), 86400L * 365L * 10L, 0, 0, sysEventTimerNotifier, &timerContext); CFRunLoopAddTimer(CFRunLoopGetCurrent(), threadData.timerRef, kCFRunLoopDefaultMode); /* * Store our runloop in a global so the main thread can use it to stop us. */ pthread_mutex_lock(&SysEventThreadMutex); SysEventRunloop = CFRunLoopGetCurrent(); pthread_cond_signal(&SysEventThreadCond); pthread_mutex_unlock(&SysEventThreadMutex); /* * Disappear into the runloop until it's stopped by the main thread. */ CFRunLoopRun(); /* * Clean up before exiting. */ if (threadData.timerRef) { CFRunLoopRemoveTimer(CFRunLoopGetCurrent(), threadData.timerRef, kCFRunLoopDefaultMode); CFRelease(threadData.timerRef); } if (threadData.sysevent.powerKernelPort) { CFRunLoopRemoveSource(CFRunLoopGetCurrent(), powerRLS, kCFRunLoopDefaultMode); IODeregisterForSystemPower(&powerNotifierObj); IOServiceClose(threadData.sysevent.powerKernelPort); IONotificationPortDestroy(powerNotifierPort); } if (storeRLS) { CFRunLoopRemoveSource(CFRunLoopGetCurrent(), storeRLS, kCFRunLoopDefaultMode); CFRunLoopSourceInvalidate(storeRLS); CFRelease(storeRLS); } if (store) CFRelease(store); pthread_exit(NULL); }
void QextSerialEnumeratorPrivate::destroy_sys() { IONotificationPortDestroy(notificationPortRef); }
void QextSerialEnumeratorPrivate::platformSpecificDestruct() { IONotificationPortDestroy(notificationPortRef); }