Fix problem with sleep proxy wakeup event
[people/sha0/mDNSResponder.git] / mDNSWindows / SystemService / Service.c
index 70d2980..5efb2dd 100644 (file)
@@ -989,6 +989,8 @@ static void HandlePowerSuspend( void * v )
 
        ( void ) v;
 
+       dlog( kDebugLevelInfo, DEBUG_NAME "HandlePowerSuspend\n" );
+
        gMDNSRecord.SystemWakeOnLANEnabled = SystemWakeForNetworkAccess( &timeout );
                                
        if ( gMDNSRecord.SystemWakeOnLANEnabled )
@@ -1009,6 +1011,8 @@ static void HandlePowerResumeSuspend( void * v )
 {
        ( void ) v;
 
+       dlog( kDebugLevelInfo, DEBUG_NAME "HandlePowerResumeSuspend\n" );
+
        if ( gSPSWakeupEvent )
        {
                CancelWaitableTimer( gSPSWakeupEvent );
@@ -1392,16 +1396,24 @@ static OSStatus ServiceSpecificRun( int argc, LPTSTR argv[] )
                                }
                                else if ( result == kWaitListSPSWakeupEvent )
                                {
+                                       __int64         temp;\r
+                                       LARGE_INTEGER   timeout;\r
+\r
+                                       dlog( kDebugLevelInfo, DEBUG_NAME "setting suspend event\n" );\r
+\r
+                                       // Stay awake for 60 seconds\r
+\r
+                                       temp                = -60 * 10000000;\r
+                                       timeout.LowPart     = (DWORD) ( temp & 0xFFFFFFFF );\r
+                                       timeout.HighPart    = (LONG)  ( temp >> 32 );\r
+\r
+                                       SetWaitableTimer( gSPSSleepEvent, &timeout, 0, NULL, NULL, TRUE );
                                }
                                else if ( result == kWaitListSPSSleepEvent )
                                {
+                                       dlog( kDebugLevelInfo, DEBUG_NAME "suspending machine\n" );\r
+                                       SetSuspendState( FALSE, FALSE, FALSE );
                                }
-                               /*
-                               else if ( result == kWaitListUDSEvent )
-                               {
-                                       gUDSCallback( ( int ) gUDSSocket, 0, NULL );
-                               }
-                               */
                                else
                                {
                                        int waitItemIndex;