- mach_port_t dead_port = ((mach_port_deleted_notification_t *)msg)->not_port;
- CFMachPortRef existing;
- /* If the CFMachPort has already been invalidated, it won't be found here. */
- __CFSpinLock(&__CFAllMachPortsLock);
- if (NULL != __CFAllMachPorts && CFDictionaryGetValueIfPresent(__CFAllMachPorts, (void *)dead_port, (const void **)&existing)) {
- CFDictionaryRemoveValue(__CFAllMachPorts, (void *)dead_port);
- CFRetain(existing);
- __CFSpinUnlock(&__CFAllMachPortsLock);
- CFMachPortInvalidate(existing);
- CFRelease(existing);
- } else {
- __CFSpinUnlock(&__CFAllMachPortsLock);
- }
- /* Delete port reference we got for this notification */
-// Don't do this, since this always fails, and could cause trouble
-// mach_port_deallocate(mach_task_self(), dead_port);
+ mach_port_t dead_port = ((mach_port_deleted_notification_t *)msg)->not_port;
+ if (((mach_dead_name_notification_t *)msg)->NDR.int_rep != NDR_record.int_rep) {
+ dead_port = CFSwapInt32(dead_port);
+ }
+ CFMachPortRef existing;
+ /* If the CFMachPort has already been invalidated, it won't be found here. */
+ __CFSpinLock(&__CFAllMachPortsLock);
+ if (NULL != __CFAllMachPorts && CFDictionaryGetValueIfPresent(__CFAllMachPorts, (void *)dead_port, (const void **)&existing)) {
+ CFDictionaryRemoveValue(__CFAllMachPorts, (void *)dead_port);
+ CFRetain(existing);
+ __CFSpinUnlock(&__CFAllMachPortsLock);
+ CFMachPortInvalidate(existing);
+ CFRelease(existing);
+ } else {
+ __CFSpinUnlock(&__CFAllMachPortsLock);
+ }
+ /* Delete port reference we got for this notification */
+ // Don't do this, since this always fails, and could cause trouble
+ // mach_port_deallocate(mach_task_self(), dead_port);