]> git.saurik.com Git - apple/xnu.git/commitdiff
xnu-124.7.tar.gz mac-os-x-1002 v124.7
authorApple <opensource@apple.com>
Sat, 9 Aug 2003 00:06:40 +0000 (00:06 +0000)
committerApple <opensource@apple.com>
Sat, 9 Aug 2003 00:06:40 +0000 (00:06 +0000)
27 files changed:
bsd/conf/version.variant
bsd/hfs/hfs_vfsutils.c
bsd/hfs/hfs_vnodeops.c
bsd/hfs/hfscommon/Catalog/Catalog.c
bsd/kern/kern_sysctl.c
bsd/kern/sys_generic.c
iokit/Drivers/hidsystem/drvAppleADBDevices/AppleADBButtons.cpp
iokit/Drivers/hidsystem/drvAppleADBDevices/AppleADBKeyboard.cpp
iokit/Drivers/hidsystem/drvAppleADBDevices/AppleADBKeyboard.h
iokit/Families/IONDRVSupport/IONDRVFramebuffer.cpp
iokit/Families/IONDRVSupport/IONDRVLibraries.cpp
iokit/Families/IOStorage/IOBlockStorageDriver.cpp
iokit/IOKit/IOServicePM.h
iokit/IOKit/adb/IOADBDevice.h
iokit/IOKit/ndrvsupport/IONDRVFramebuffer.h
iokit/Kernel/IOServicePM.cpp
iokit/KernelConfigTables.cpp
iokit/conf/version.variant
libkern/conf/version.variant
libsa/conf/version.variant
osfmk/conf/kernelversion.variant
osfmk/conf/version.variant
osfmk/kern/bsd_kern.c
osfmk/kern/sched_prim.c
osfmk/kern/task.c
osfmk/kern/thread_act.c
pexpert/conf/version.variant

index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0cfbf08886fca9a91cb753ec8734c84fcbe52c9f 100644 (file)
@@ -0,0 +1 @@
+2
index 93062300ddeb440f65713418feb18522a7d7374b..36c3e550e3c2f37dbc268a5c672eebd3008dc32f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2001 Apple Computer, Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
@@ -2866,6 +2866,7 @@ void UnpackCommonAttributeBlock(struct attrlist *alist,
                catInfo->nodeData.cnd_contentModDate = to_hfs_time((UInt32)((struct timespec *)attrbufptr)->tv_sec);
                VTOH(vp)->h_meta->h_mtime = (UInt32)((struct timespec *)attrbufptr)->tv_sec;
                ++((struct timespec *)attrbufptr);
+               hp->h_nodeflags &= ~IN_UPDATE;
 #if HFS_DIAGNOSTIC
                a &= ~ATTR_CMN_MODTIME;
 #endif
@@ -2874,6 +2875,7 @@ void UnpackCommonAttributeBlock(struct attrlist *alist,
                catInfo->nodeData.cnd_attributeModDate = to_hfs_time((UInt32)((struct timespec *)attrbufptr)->tv_sec);
                VTOH(vp)->h_meta->h_ctime = (UInt32)((struct timespec *)attrbufptr)->tv_sec;
                ++((struct timespec *)attrbufptr);
+               hp->h_nodeflags &= ~IN_CHANGE;
 #if HFS_DIAGNOSTIC
                a &= ~ATTR_CMN_CHGTIME;
 #endif
@@ -2882,6 +2884,7 @@ void UnpackCommonAttributeBlock(struct attrlist *alist,
                catInfo->nodeData.cnd_accessDate = to_hfs_time((UInt32)((struct timespec *)attrbufptr)->tv_sec);
                VTOH(vp)->h_meta->h_atime = (UInt32)((struct timespec *)attrbufptr)->tv_sec;
                ++((struct timespec *)attrbufptr);
+               hp->h_nodeflags &= ~IN_ACCESS;
 #if HFS_DIAGNOSTIC
                a &= ~ATTR_CMN_ACCTIME;
 #endif
index 14a784ee927516ce2a06de0d4e7b399066dc2f71..f922b4471c83b2bec0aca98dbff4d9c2cd47adf0 100644 (file)
@@ -3227,7 +3227,7 @@ struct vop_readdir_args /* {
                        goto Exit;
        }
        
-       diroffset = uio->uio_offset;
+       diroffset = uio->uio_offset - sizeof(rootdots);
 
        /* lock catalog b-tree */
        retval = hfs_metafilelocking(VTOHFS(ap->a_vp), kHFSCatalogFileID, LK_SHARED, p);
index c71d5c7f9512d74cdd82bb1a0e621ee9f021faa3..d200f63ecf9f84701c98a4ca3ac13f57a69be9ca 100644 (file)
@@ -797,7 +797,6 @@ GetDirEntrySize(BTreeIterator *bip, ExtendedVCB * vol)
                                    cnp->ustr.length * sizeof(UniChar), ':', 0);
                if (utf8chars > kdirentMaxNameBytes)
                        utf8chars = kdirentMaxNameBytes;
-               utf8chars++;  /* account for NULL termination */
        } else { /* hfs */
                cnp = (CatalogName*) ckp->hfs.nodeName;
                result = hfs_to_utf8(vol, cnp->pstr, kdirentMaxNameBytes + 1,
@@ -817,7 +816,7 @@ GetDirEntrySize(BTreeIterator *bip, ExtendedVCB * vol)
 OSErr
 PositionIterator(CatalogIterator *cip, UInt32 offset, BTreeIterator *bip, UInt16 *op)
 {
-#define CAT_START_OFFSET (2 * sizeof(struct hfsdotentry))
+#define CAT_START_OFFSET 0
        ExtendedVCB *   vol;
        FCB *           fcb;
        OSErr           result = 0;
index c7332ad0517ae7dcb575a3ded7141b79887ded45..047eb70b1a38cb0dd8958324dd1a5629e86e302e 100644 (file)
@@ -837,6 +837,7 @@ again:
                        break;
                }
                if (buflen >= sizeof(struct kinfo_proc)) {
+                       bzero(&kproc, sizeof(struct kinfo_proc));
                        fill_proc(p, &kproc, doingzomb);
                        if (error = copyout((caddr_t)&kproc, &dp->kp_proc,
                            sizeof(struct kinfo_proc)))
@@ -882,6 +883,12 @@ fill_eproc(p, ep)
 {
        register struct tty *tp;
 
+       /*
+        * Skip zombie processes.
+        */
+       if (p->p_stat == SZOMB)
+               return;
+
        ep->e_paddr = p;
        ep->e_sess = p->p_pgrp->pg_session;
        ep->e_pcred = *p->p_cred;
index b8c6e975e59f2e6a92cca0afe10967e6b38c726f..cf5878004393bd4e4602c720be00e8827309dc01 100644 (file)
@@ -720,13 +720,10 @@ selrecord(selector, sip)
        } else {
                sip->si_thread = my_thread;
                splx(oldpri);
+               act_reference(current_act());
                if (selthread) {
-                       /* thread_deallocate(selthread); */
                        act_deallocate(getact_thread(selthread));
                }
-               /* do I need act reference ??? */
-               /* thread_reference(sip->si_thread); */
-               act_reference(getact_thread(sip->si_thread));
        }
 
        return;
index 1810d185426861a605fc2ea2f89c5edc4687ba57..b0c7168f7b2dc6b3759a8f9c08a5caefe18c39c4 100644 (file)
@@ -20,6 +20,7 @@
  * @APPLE_LICENSE_HEADER_END@
  */
 #include "AppleADBButtons.h"
+#include "AppleADBKeyboard.h"
 #include <IOKit/IOLib.h>
 #include <IOKit/pwr_mgt/IOPM.h>
 #include <IOKit/hidsystem/IOHIDTypes.h>
@@ -88,6 +89,24 @@ UInt32 AppleADBButtons::interfaceID()
 
 UInt32 AppleADBButtons::deviceType()
 {
+    //if initial id is 31 then this is a post-WallStreet PowerBook, so 
+    //look for a AppleADBKeyboard driver and return the handler ID from it.
+    //Note though that the ADB keyboard driver may not exist.
+    if (_initial_handler_id == 31)
+    {
+       mach_timespec_t     t;
+       AppleADBKeyboard  *adbkeyboard;
+
+       t.tv_sec = 2;   
+       t.tv_nsec = 0;
+       adbkeyboard = (AppleADBKeyboard *)waitForService(serviceMatching("AppleADBKeyboard"), &t);
+       if (adbkeyboard)
+       {
+           return adbkeyboard->deviceType();
+       }
+
+    }
+
     return adbDevice->handlerID();
 }
 
index 42657151cd84fdc0b6dfe18549eba8223770f131..6d8d7cd32de4ca0941e2ef46c0cd741f3f5688c8 100644 (file)
@@ -93,23 +93,18 @@ return NX_EVS_DEVICE_INTERFACE_ADB;
 UInt32 AppleADBKeyboard::deviceType ( void )
 {
     UInt32     id;     //We need handler ID to remap adjustable JIS keyboard
-    
-    id = adbDevice->handlerID();
-    if (id == 18)  //Adjustable JIS
-    {
-       kmapConvert[0x32] = 0x35; //tilde to ESC 
-    }
     IORegistryEntry    *regEntry;
     OSData *           data = 0;
     UInt32             *dataptr;
-    
+        
     id = adbDevice->handlerID();
     if (id == 18)  //Adjustable JIS
     {
        kmapConvert[0x32] = 0x35; //tilde to ESC 
     }
 
-    if ((id == kgestaltPwrBkEKDomKbd) || (id == kgestaltPwrBkEKISOKbd) || (id == kgestaltPwrBkEKJISKbd))
+    if ((id == kgestaltPwrBkEKDomKbd) || (id == kgestaltPwrBkEKISOKbd) || 
+       (id == kgestaltPwrBkEKJISKbd) || (id == kgestaltPwrBk99JISKbd))
     {  
        if( (regEntry = IORegistryEntry::fromPath( "/pci@f2000000/mac-io/via-pmu/adb/keyboard", gIODTPlane ))) 
        {
@@ -122,7 +117,7 @@ UInt32 AppleADBKeyboard::deviceType ( void )
            regEntry->release();
        }
     }    
-
+        
     return id;
 }
 
index 6ab4ee976d39d3a2ab564dc983303994ccca6775..038d15c0b5f90309f225a8b3cda7a4d5a5c4dcd6 100644 (file)
@@ -25,7 +25,8 @@
 enum {
     kgestaltPwrBkEKDomKbd = 0xc3,
     kgestaltPwrBkEKISOKbd = 0xc4,
-    kgestaltPwrBkEKJISKbd = 0xc5
+    kgestaltPwrBkEKJISKbd = 0xc5,
+    kgestaltPwrBk99JISKbd = 0xc9
 };
 
 class AppleADBKeyboard :  public IOHIKeyboard
@@ -39,7 +40,6 @@ void setNumLockFeedback ( bool to );
 UInt32 maxKeyCodes ( void );
 const unsigned char * defaultKeymapOfLength (UInt32 * length );
 UInt32 interfaceID ( void );
-UInt32 deviceType ( void );
 bool doesKeyLock ( unsigned key);
 unsigned getLEDStatus (void );
 bool programmerKey;
@@ -49,6 +49,7 @@ AbsoluteTime  debuggerTime;
 
 public:
 
+UInt32 deviceType ( void );
 IOADBDevice *  adbDevice;
 UInt16         turnLEDon;              // used by setAlphaLockFeedback mechanism
 UInt16         LEDStatus;              //For ADB device TALK commands
index 472e54d9ec7efd66872f422a4c09423cd8e3c332..18119f96df432e8c8d68e106d87f75b6d202387a 100644 (file)
@@ -46,6 +46,8 @@
 
 #include <string.h>
 
+#define kAppleAudioVideoJackStateKey   "AppleAudioVideoJackState"
+
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
 
 class IOATINDRV : public IONDRVFramebuffer
@@ -242,6 +244,12 @@ IOReturn IONDRVFramebuffer::enableController( void )
 
     if( kIOReturnSuccess == err) do {
 
+        // find out about onboard audio/video jack state
+        // OSObject * notify =
+        addNotification( gIOPublishNotification,
+                         resourceMatching(kAppleAudioVideoJackStateKey), 
+                         _videoJackStateChangeHandler, this, 0 );
+
         ignore_zero_fault( true );
        err = checkDriver();
         ignore_zero_fault( false );
@@ -273,6 +281,25 @@ IOReturn IONDRVFramebuffer::enableController( void )
     return( err);
 }
 
+bool IONDRVFramebuffer::_videoJackStateChangeHandler( void * target, void * ref,
+                                                        IOService * resourceService )
+{
+    IONDRVFramebuffer * self = (IONDRVFramebuffer *) target;
+    IOReturn           err;
+    UInt32             jackData;
+
+    OSObject * jackValue = resourceService->getProperty(kAppleAudioVideoJackStateKey);
+    if( !jackValue)
+        return( true );
+
+    jackData = (jackValue == kOSBooleanTrue);
+
+    self->nub->setProperty( kAppleAudioVideoJackStateKey, &jackData, sizeof(jackData) );
+    resourceService->removeProperty(kAppleAudioVideoJackStateKey);
+
+    return( true );
+}
+
 IODeviceMemory * IONDRVFramebuffer::getVRAMRange( void )
 {
     if( vramMemory)
index 565126fefbda3c69de100b3c6a8d24e19b5f0802..24ab2ee5cd35d7c38a57ac5c4825daac1e83e23e 100644 (file)
@@ -655,7 +655,8 @@ _eRegistryCStrEntryLookup(  const RegEntryID *      parentEntry,
     char *             buf;
     char *             cvtPath;
     char               c;
-#define kDTRoot        "Devices:device-tree:"
+#define kDTRoot                "Devices:device-tree:"
+#define kMacIORoot     "Devices:device-tree:pci:mac-io:"
 
     if( parentEntry) {
         REG_ENTRY_TO_OBJ( parentEntry, regEntry)
@@ -669,6 +670,10 @@ _eRegistryCStrEntryLookup(  const RegEntryID *     parentEntry,
     cvtPath = buf;
     if( ':' == path[0])
        path++;
+    else if( 0 == strncmp( path, kMacIORoot, strlen( kMacIORoot ))) {
+       path += strlen( kMacIORoot ) - 7;
+       regEntry = 0;
+    }
     else if( 0 == strncmp( path, kDTRoot, strlen( kDTRoot ))) {
        path += strlen( kDTRoot ) - 1;
        regEntry = 0;
index 8e843b49a5b5fa9473039b432f1900f6a572d19a..345e55b5610a68bed4e3465f3a1adc524b425b24 100644 (file)
@@ -1759,7 +1759,7 @@ IOByteCount IODeblocker::readBytes( IOByteCount offset,
 
     for ( ; index < _chunksCount && withLength; index++)
     {
-        IOByteCount copy   = min(_chunks[index].length, withLength);
+        IOByteCount copy   = min(_chunks[index].length - offset, withLength);
         IOByteCount copied = _chunks[index].buffer->readBytes(
                                     /* offset */ offset + _chunks[index].offset,
                                     /* bytes  */ bytes,
@@ -1798,7 +1798,7 @@ IOByteCount IODeblocker::writeBytes( IOByteCount  offset,
 
     for ( ; index < _chunksCount && withLength; index++)
     {
-        IOByteCount copy   = min(_chunks[index].length, withLength);
+        IOByteCount copy   = min(_chunks[index].length - offset, withLength);
         IOByteCount copied = _chunks[index].buffer->writeBytes(
                                     /* offset */ offset + _chunks[index].offset,
                                     /* bytes  */ bytes,
index 7f958c7c92e7916a3d5b8c94a4c4673eb3f2f37a..2b48bb3379c26ff311b6e9dc8281b0bce5c71734 100644 (file)
@@ -148,6 +148,9 @@ class IOPMpriv : public OSObject
     /*! @field device_active                   true: there has been device activity since last idle timer expiration  */
     bool                       device_active;
 
+    /*! @field device_active_timestamp    time in ticks of last activity */
+    AbsoluteTime                device_active_timestamp;
+
     /*! @field driverDesire
 This is the power state desired by our controlling driver.  It is initialized to myCurrentState and is changed
 when the controlling driver calls changePowerStateTo.   A change in driverDesire may cause a change in ourDesiredPowerState.
index 882963ad0f7127576319bd5f6f04a670008c6f4e..c8c1d7c13baecec8d04b9d5d3d5f8f39a043ab6f 100644 (file)
@@ -19,6 +19,9 @@
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
+#ifndef IOADBDEVICE_H
+#define IOADBDEVICE_H
+
 #include <IOKit/IOService.h>
 #include <IOKit/adb/adb.h>
 #include <IOKit/adb/IOADBBus.h>
@@ -53,3 +56,6 @@ IOReturn setHandlerID ( UInt8 handlerID );
 void * busRef ( void );
 
 };
+
+#endif
+
index d81e8f29a8801630eb28389fdecc57c45d852727..f285d98beffeacf89d8329997d52ee004e95a94d 100644 (file)
@@ -154,6 +154,8 @@ private:
     static const IOTVector * _undefinedSymbolHandler( void * self, 
                             const char * libraryName, const char * symbolName );
     void displayI2CPower( bool enable );
+    static bool _videoJackStateChangeHandler( void * target, void * ref,
+                                                IOService * resourceService );
 
 public:
     virtual IOReturn doControl( UInt32 code, void * params );
index 424f3f79ca0ffe281b625edcd332c9ea4141709f..4c72153e3fc3fe3d4890dc102219df0f4a36ea99 100644 (file)
@@ -34,6 +34,7 @@
 #include "IOKit/pwr_mgt/IOPMchangeNoteList.h"
 #include "IOKit/pwr_mgt/IOPMlog.h"
 #include "IOKit/pwr_mgt/IOPowerConnection.h"
+#include <kern/clock.h>
 
 static void ack_timer_expired(thread_call_param_t);
 static void settle_timer_expired(thread_call_param_t);
@@ -1188,6 +1189,8 @@ unsigned long IOService::currentPowerConsumption ( void )
 
 bool IOService::activityTickle ( unsigned long type, unsigned long stateNumber=0 )
 {
+    AbsoluteTime uptime;
+
     if ( type == kIOPMSuperclassPolicy1 ) {
         if ( (priv->activityLock == NULL) ||
              (pm_vars->theControllingDriver == NULL) ||
@@ -1196,6 +1199,10 @@ bool IOService::activityTickle ( unsigned long type, unsigned long stateNumber=0
         }
         IOTakeLock(priv->activityLock);
         priv->device_active = true;
+
+        clock_get_uptime(&uptime);
+        priv->device_active_timestamp = uptime;
+
         if ( pm_vars->myCurrentState >= stateNumber) {
             IOUnlock(priv->activityLock);
             return true;
@@ -1285,7 +1292,38 @@ IOReturn  IOService::setIdleTimerPeriod ( unsigned long period )
 //*********************************************************************************
 void IOService::start_PM_idle_timer ( void )
 {
-    priv->timerEventSrc->setTimeout(priv->idle_timer_period, NSEC_PER_SEC);
+    AbsoluteTime uptime;
+    AbsoluteTime delta;
+    UInt64       delta_ns;
+    UInt64       delta_secs;
+    UInt64       delay_secs;
+
+    IOLockLock(priv->activityLock);
+
+    clock_get_uptime(&uptime);
+
+   /* Calculate time difference using funky macro from clock.h.
+    */
+    delta = uptime;
+    SUB_ABSOLUTETIME(&delta, &(priv->device_active_timestamp));
+
+   /* Figure it in seconds.
+    */
+    absolutetime_to_nanoseconds(delta, &delta_ns);
+    delta_secs = delta_ns / NSEC_PER_SEC;
+
+   /* Be paranoid about delta somehow exceeding timer period.
+    */
+    if (delta_secs < priv->idle_timer_period ) {
+        delay_secs = priv->idle_timer_period - delta_secs;
+    } else {
+        delay_secs = priv->idle_timer_period;
+    }
+
+    priv->timerEventSrc->setTimeout(delay_secs, NSEC_PER_SEC);
+
+    IOLockUnlock(priv->activityLock);
+    return;
 }
 
 
index 8070a2eaf9713624e96514448adb45e1795ecbef..f7f4e6ec464550c8b108bb4ab41673e2e7e4b257 100644 (file)
  */
 const char * gIOKernelKmods =
 "{
-    'com.apple.kernel'                         = '1.0.0b1';
-    'com.apple.kernel.bsd'                     = '1.0.0b1';
-    'com.apple.kernel.iokit'                   = '1.0.0b1';
-    'com.apple.kernel.libkern'                 = '1.0.0b1';
-    'com.apple.kernel.mach'                    = '1.0.0b1';
-    'com.apple.iokit.IOADBFamily'              = '1.0.0b1';
-    'com.apple.iokit.IOCDStorageFamily'        = '1.0.0b1';
-    'com.apple.iokit.IODVDStorageFamily'       = '1.0.0b1';
-    'com.apple.iokit.IOGraphicsFamily'         = '1.0.0b1';
-    'com.apple.iokit.IOHIDSystem'              = '1.0.0b1';
-    'com.apple.iokit.IONDRVSupport'            = '1.0.0b1';
-    'com.apple.iokit.IONetworkingFamily'       = '1.0.0b1';
-    'com.apple.iokit.IOPCIFamily'              = '1.0.0b1';
-    'com.apple.iokit.IOStorageFamily'          = '1.0.0b1';
-    'com.apple.iokit.IOSystemManagementFamily' = '1.0.0b1';
+    'com.apple.kernel'                         = '1.3.2';
+    'com.apple.kernel.bsd'                     = '1.0.2';
+    'com.apple.kernel.iokit'                   = '1.0.2';
+    'com.apple.kernel.libkern'                 = '1.0.2';
+    'com.apple.kernel.mach'                    = '1.0.2';
+    'com.apple.iokit.IOADBFamily'              = '1.0.2';
+    'com.apple.iokit.IOCDStorageFamily'        = '1.0.2';
+    'com.apple.iokit.IODVDStorageFamily'       = '1.0.2';
+    'com.apple.iokit.IOGraphicsFamily'         = '1.0.2';
+    'com.apple.iokit.IOHIDSystem'              = '1.0.2';
+    'com.apple.iokit.IONDRVSupport'            = '1.0.2';
+    'com.apple.iokit.IONetworkingFamily'       = '1.0.2';
+    'com.apple.iokit.IOPCIFamily'              = '1.0.2';
+    'com.apple.iokit.IOStorageFamily'          = '1.0.2';
+    'com.apple.iokit.IOSystemManagementFamily' = '1.0.2';
 }";
 
 
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0cfbf08886fca9a91cb753ec8734c84fcbe52c9f 100644 (file)
@@ -0,0 +1 @@
+2
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0cfbf08886fca9a91cb753ec8734c84fcbe52c9f 100644 (file)
@@ -0,0 +1 @@
+2
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0cfbf08886fca9a91cb753ec8734c84fcbe52c9f 100644 (file)
@@ -0,0 +1 @@
+2
index 8b137891791fe96927ad78e64b0aad7bded08bdc..0cfbf08886fca9a91cb753ec8734c84fcbe52c9f 100644 (file)
@@ -1 +1 @@
-
+2
index 8b137891791fe96927ad78e64b0aad7bded08bdc..0cfbf08886fca9a91cb753ec8734c84fcbe52c9f 100644 (file)
@@ -1 +1 @@
-
+2
index 24017dd53bf99d12b3da04977fa5342faca7b518..0c03a919376c1fd02a957ff3da4283adf0ffeac2 100644 (file)
@@ -427,7 +427,8 @@ current_thread_aborted (
 {
        thread_t th = current_thread();
 
-       return(!th->top_act || (th->state & TH_ABORT)); 
+       return(!th->top_act ||
+              ((th->state & TH_ABORT) && (th->interruptible))); 
 }
 
 /*
index ae49e69ca9b88c79e1c222e5e0c31c5ba4f121ed..e2da65ad15f2b2f3f84656914c989049ba25cf16 100644 (file)
@@ -610,13 +610,15 @@ thread_stop(
        wake_lock(thread);
 
        while (thread->state & TH_SUSP) {
+               int wait_result;
+
                thread->wake_active = TRUE;
                assert_wait((event_t)&thread->wake_active, THREAD_ABORTSAFE);
                wake_unlock(thread);
                splx(s);
 
-               thread_block((void (*)(void)) 0);
-               if (current_thread()->wait_result != THREAD_AWAKENED)
+               wait_result = thread_block((void (*)(void)) 0);
+               if (wait_result != THREAD_AWAKENED)
                        return (FALSE);
 
                s = splsched();
@@ -694,6 +696,8 @@ thread_wait(
        wake_lock(thread);
 
        while (thread->state & (TH_RUN/*|TH_UNINT*/)) {
+               int wait_result;
+
                if (thread->last_processor != PROCESSOR_NULL)
                        cause_ast_check(thread->last_processor);
 
@@ -702,18 +706,16 @@ thread_wait(
                wake_unlock(thread);
                splx(s);
 
-               thread_block((void (*)(void))0);
-               if (current_thread()->wait_result != THREAD_AWAKENED)
-                       return (FALSE);
+               wait_result = thread_block((void (*)(void))0);
+               if (wait_result != THREAD_AWAKENED)
+                       return FALSE;
 
                s = splsched();
                wake_lock(thread);
        }
-
        wake_unlock(thread);
        splx(s);
-
-       return (TRUE);
+       return TRUE;
 }
 
 
index 0eaf47eaa27d11f0b17a64082ff52367ba649fff..bea0f27d0d95d2b4142d946500113cd7439c7def 100644 (file)
@@ -623,6 +623,8 @@ task_terminate_internal(
 {
        thread_act_t    thr_act, cur_thr_act;
        task_t          cur_task;
+       thread_t        cur_thread;
+       boolean_t       interrupt_save;
 
        assert(task != kernel_task);
 
@@ -676,6 +678,14 @@ task_terminate_internal(
        if (cur_task != task)
                task_unlock(cur_task);
 
+       /*
+        * Make sure the current thread does not get aborted out of
+        * the waits inside these operations.
+        */
+       cur_thread = current_thread();
+       interrupt_save = cur_thread->interruptible;
+       cur_thread->interruptible = FALSE;
+
        /*
         *      Indicate that we want all the threads to stop executing
         *      at user space by holding the task (we would have held
@@ -696,22 +706,20 @@ task_terminate_internal(
         *      clean up most of the thread resources.  Then it will be
         *      handed over to the reaper, who will finally remove the
         *      thread from the task list and free the structures.
-        *
-        *      We can't terminate the current activation yet, because
-        *      it has to wait for the others in an interruptible state.
-        *      We may also block interruptibly during the rest of the
-        *      cleanup.  Wait until the very last to terminate ourself.
-        *
-        *      But if we have virtual machine state, we need to clean
-        *      that up now, because it may be holding wirings the task's
-        *      map that would get stuck in the vm_map_remove() below.
          */
        queue_iterate(&task->thr_acts, thr_act, thread_act_t, thr_acts) {
-               if (thr_act != cur_thr_act)
                        thread_terminate_internal(thr_act);
-               else
-                       act_virtual_machine_destroy(thr_act);
        }
+
+       /*
+        *      Clean up any virtual machine state/resources associated
+        *      with the current activation because it may hold wiring
+        *      and other references on resources we will be trying to
+        *      release below.
+        */
+       if (cur_thr_act->task == task)
+               act_virtual_machine_destroy(cur_thr_act);
+
        task_unlock(task);
 
        /*
@@ -743,11 +751,14 @@ task_terminate_internal(
                             task->map->max_offset, VM_MAP_NO_FLAGS);
 
        /*
-        *      Finally, mark ourself for termination and then
-        *      deallocate the task's reference to itself.
+        * We no longer need to guard against being aborted, so restore
+        * the previous interruptible state.
+        */
+       cur_thread->interruptible = interrupt_save;
+
+       /*
+        * Get rid of the task active reference on itself.
         */
-       if (task == cur_task)
-               thread_terminate(cur_thr_act);
        task_deallocate(task);
 
        return(KERN_SUCCESS);
@@ -815,19 +826,22 @@ task_halt(
                 *      clean up most of the thread resources.  Then it will be
                 *      handed over to the reaper, who will finally remove the
                 *      thread from the task list and free the structures.
-                *
-                *      If the current thread has any virtual machine state
-                *      associated with it, clean that up now before we try
-                *      to clean up the task VM and port spaces.
                 */
                queue_iterate(&task->thr_acts, thr_act, thread_act_t,thr_acts) {
                        if (thr_act != cur_thr_act)
                                thread_terminate_internal(thr_act);
-                       else
-                               act_virtual_machine_destroy(thr_act);
                }
                task_release_locked(task);
        }
+
+       /*
+        *      If the current thread has any virtual machine state
+        *      associated with it, we need to explicitly clean that
+        *      up now (because we did not terminate the current act)
+        *      before we try to clean up the task VM and port spaces.
+        */
+       act_virtual_machine_destroy(cur_thr_act);
+
        task_unlock(task);
 
        /*
@@ -840,10 +854,18 @@ task_halt(
         */
        task_subsystem_destroy_all(task);
 
+#if 0
        /*
         *      Destroy the IPC space, leaving just a reference for it.
         */
-#if 0
+       /*
+        * Lookupd will break if we enable this cleaning, because it
+        * uses a slimey trick that depends upon the portspace not
+        * being cleaned up across exec (it passes the lookupd server
+        * port to the child after a restart using knowledge of this
+        * bug in past implementations).  We need to fix lookupd to
+        * keep from leaking ports across exec.
+        */
        if (!task->kernel_loaded)
                ipc_space_clean(task->itk_space);
 #endif
index 459cf608af68e5afd4d844512a65a32c44bcc5a0..9a97f50a6eaba53bc028c7309cb4664e5e6a2d9b 100644 (file)
@@ -124,9 +124,6 @@ thread_terminate_internal(
        task_t          task;
        struct ipc_port *iplock;
        kern_return_t   ret;
-#if    NCPUS > 1
-       boolean_t       held;
-#endif /* NCPUS > 1 */
 
 #if    THREAD_SWAPPER
        thread_swap_disable(thr_act);
@@ -138,6 +135,9 @@ thread_terminate_internal(
                return(KERN_TERMINATED);
        }
 
+       act_disable_task_locked(thr_act);
+       ret = act_abort(thr_act,FALSE);
+
 #if    NCPUS > 1
        /* 
         * Make sure this thread enters the kernel
@@ -146,34 +146,17 @@ thread_terminate_internal(
                thread_hold(thr_act);
                act_unlock_thread(thr_act);
 
-               if (!thread_stop_wait(thread)) {
+               if (thread_stop_wait(thread))
+                       thread_unstop(thread);
+               else
                        ret = KERN_ABORTED;
-                       (void)act_lock_thread(thr_act);
-                       thread_release(thr_act);
-                       act_unlock_thread(thr_act);
-                       return (ret);
-               }
 
-               held = TRUE;
                (void)act_lock_thread(thr_act);
-       } else {
-               held = FALSE;
+               thread_release(thr_act);
        }
 #endif /* NCPUS > 1 */
 
-       assert(thr_act->active);
-       act_disable_task_locked(thr_act);
-       ret = act_abort(thr_act,FALSE);
        act_unlock_thread(thr_act);
-
-#if    NCPUS > 1
-       if (held) {
-               thread_unstop(thread);
-               (void)act_lock_thread(thr_act);
-               thread_release(thr_act);
-               act_unlock_thread(thr_act);
-       }
-#endif /* NCPUS > 1 */
        return(ret);
 }
 
@@ -509,8 +492,7 @@ act_abort( thread_act_t thr_act, int chain_break )
        thread_lock(thr_act->thread);
        if (thr_act->thread->top_act == thr_act) {
            thr_act->thread->state |= TH_ABORT;
-           if (thr_act->thread->state & TH_ABORT)
-               clear_wait_internal(thr_act->thread, THREAD_INTERRUPTED);
+           clear_wait_internal(thr_act->thread, THREAD_INTERRUPTED);
            thread_unlock(thr_act->thread);
            splx(spl);
            install_special_handler(thr_act);
@@ -1459,12 +1441,9 @@ install_special_handler(
 #endif /* MACH_ASSERT */
 
        spl = splsched();
-       if (thread)
-               thread_lock(thread);
+       thread_lock(thread);
        install_special_handler_locked(thr_act);
-       act_set_apc(thr_act);
-       if (thread)
-               thread_unlock(thread);
+       thread_unlock(thread);
        splx(spl);
 }
 
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0cfbf08886fca9a91cb753ec8734c84fcbe52c9f 100644 (file)
@@ -0,0 +1 @@
+2