<rdar://problem/7324365> Windows machine name does not disappear from Mac Finder...
authorsherscher@apple.com <sherscher@apple.com@214c2c4a-bf3b-4dcf-9390-e4dd3010487d>
Thu, 22 Oct 2009 18:11:41 +0000 (18:11 +0000)
committersherscher@apple.com <sherscher@apple.com@214c2c4a-bf3b-4dcf-9390-e4dd3010487d>
Thu, 22 Oct 2009 18:11:41 +0000 (18:11 +0000)
git-svn-id: http://svn.macosforge.org/repository/mDNSResponder/trunk@6750 214c2c4a-bf3b-4dcf-9390-e4dd3010487d

mDNSWindows/SystemService/Service.c
mDNSWindows/mDNSWin32.c

index 3e0aa27..760ff20 100644 (file)
@@ -222,8 +222,6 @@ typedef DWORD ( WINAPI * GetIpInterfaceEntryFunctionPtr )( PMIB_IPINTERFACE_ROW
 mDNSlocal HMODULE                                                              gIPHelperLibraryInstance                = NULL;
 mDNSlocal GetIpInterfaceEntryFunctionPtr               gGetIpInterfaceEntryFunctionPtr = NULL;
 
-mDNSBool StrictUnicastOrdering = mDNSfalse;
-
 
 #if 0
 #pragma mark -
@@ -1258,20 +1256,36 @@ static OSStatus ServiceSpecificRun( int argc, LPTSTR argv[] )
 
                while ( !gEventSourceListChanged )
                {
-                       mDNSs32 interval;
+                       mDNSs32 nextTimerEvent;
 
                        // Give the mDNS core a chance to do its work and determine next event time.
-                       
-                       interval = mDNS_Execute( &gMDNSRecord ) - mDNS_TimeNow( &gMDNSRecord );
-                       interval = udsserver_idle( interval );
 
-                       if      (interval < 0)                                          interval = 0;
-                       else if (interval > (0x7FFFFFFF / 1000))        interval = 0x7FFFFFFF / mDNSPlatformOneSecond;
-                       else                                                                            interval = (interval * 1000) / mDNSPlatformOneSecond;
-                       
+                       nextTimerEvent = udsserver_idle( mDNS_Execute( &gMDNSRecord ) - mDNS_TimeNow( &gMDNSRecord ) );
+
+                       if      ( nextTimerEvent < 0)                                   nextTimerEvent = 0;
+                       else if ( nextTimerEvent > (0x7FFFFFFF / 1000)) nextTimerEvent = 0x7FFFFFFF / mDNSPlatformOneSecond;
+                       else                                                                                    nextTimerEvent = ( nextTimerEvent * 1000) / mDNSPlatformOneSecond;
+
+                       if ( gMDNSRecord.ShutdownTime )
+                       {
+                               mDNSs32 now = mDNS_TimeNow( &gMDNSRecord );
+
+                               if ( mDNS_ExitNow( &gMDNSRecord, now ) )
+                               {
+                                       mDNS_FinalExit( &gMDNSRecord );
+                                       done = TRUE;
+                                       break;
+                               }
+
+                               if ( nextTimerEvent - gMDNSRecord.ShutdownTime >= 0 )
+                               {
+                                       nextTimerEvent = gMDNSRecord.ShutdownTime;
+                               }
+                       }
+
                        // Wait until something occurs (e.g. cancel, incoming packet, or timeout).
                                                
-                       result = WaitForMultipleObjectsEx( ( DWORD ) waitListCount, waitList, FALSE, (DWORD) interval, TRUE );
+                       result = WaitForMultipleObjectsEx( ( DWORD ) waitListCount, waitList, FALSE, (DWORD) nextTimerEvent, TRUE );
                        check( result != WAIT_FAILED );
 
                        if ( result != WAIT_FAILED )
@@ -1293,7 +1307,8 @@ static OSStatus   ServiceSpecificRun( int argc, LPTSTR argv[] )
                                        // Stop event. Set the done flag and break to exit.
                                        
                                        dlog( kDebugLevelVerbose, DEBUG_NAME "stopping...\n" );
-                                       done = TRUE;
+                                       udsserver_exit();
+                                       mDNS_StartExit( &gMDNSRecord );
                                        break;
                                }
                                else if( result == kWaitListInterfaceListChangedEvent )
@@ -1544,16 +1559,6 @@ static void      ServiceSpecificFinalize( int argc, LPTSTR argv[] )
                UnregisterWaitableEvent( &gMDNSRecord, gEventSourceList->event );
        }
 
-       //
-       // give a chance for the udsserver code to clean up
-       //
-       udsserver_exit();
-
-       //
-       // close down the mDNSCore
-       //
-       mDNS_Close(&gMDNSRecord);
-
        //
        // clean up the notifications
        //
index 1e7b835..c3cadd8 100755 (executable)
@@ -4540,6 +4540,10 @@ CheckFileShares( mDNS * const m )
 
        check( m );
 
+       // Only do this if we're not shutting down
+
+       require_action_quiet( !m->ShutdownTime, exit, err = kNoErr );
+
        err = RegCreateKey( HKEY_LOCAL_MACHINE, kServiceParametersNode L"\\Services\\SMB", &key );
 
        if ( !err )