Jump to content

simisimi88

Members
  • Posts

    1
  • Joined

  • Last visited

About simisimi88

  • Birthday 09/13/1990

Profile Information

  • Location
    Germany, Munich

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

simisimi88's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. One of my customers has stil the problem with stopping service... OS: WinServer'08R2 x64 and Win7 x64 Services.au3 V4 My _Main-Func : Func _Main($iArg, $sArgs) #Region -- STOP -- Service Start If $bDebug Then Debug("***** SERVICE START *******") If Not _Service_ReportStatus($SERVICE_RUNNING, $NO_ERROR, 0) Then If $bAU3ServiceDebug Then logprint("Error sending running status, exiting") _Service_ReportStatus($SERVICE_STOPPED, _WinAPI_GetLastError(), 0) Exit EndIf _Service_ReportStatus($SERVICE_START_PENDING, $NO_ERROR, 10) _Service_ReportStatus($SERVICE_RUNNING, $NO_ERROR, 30) If $bDebug Then Debug("Started Main.") $bServiceRunning = True #EndRegion -- STOP -- Service Start While $bServiceRunning ; REQUIRED ( dont change variable name ) ; there are several ways to find that service have to be stoped - $Running flag in loop is the first method #Region --> mycode _Service_ReportStatus($SERVICE_RUNNING, $NO_ERROR, 30) If Not $bServiceRunning Then logprint("Service stopped!") TCPShutdown() ProcessClose(@AutoItPID) ExitLoop EndIf USleep(5000, $NTDLL) ;This is needed because TCPTimeout is disabled. Without this it will run one core at ~100%. ;The USleep function takes MICROseconds, not milliseconds, so 1000 = 1ms delay. ;When working with this granularity, you have to take in to account the time it takes to complete USleep(). ;1000us (1ms) is about as fast as this should be set. If you need more performance, set this from 5000 to 1000, ;but doing so will make it consume a bit more CPU time to get that extra bit of performance. Check() ;Check recv buffers and do things´ If TimerDiff($CleanupTimer) > 1000 Then ;If it has been more than 1000ms since Cleanup() was last called, call it now $CleanupTimer = TimerInit() ;Reset $CleanupTimer, so it is ready to be called again Cleanup() ;Clean up the dead connections EndIf Local $iSock = TCPAccept($Listen) ;See if anything wants to connect If $iSock = -1 Then ContinueLoop ;If nothing wants to connect, restart at the top of the loop Local $iSize = UBound($Clients, 1) ;Something wants to connect, so get the number of people currently connected here If $iSize - 1 > $MaxClients And $MaxClients > 0 Then ;If $MaxClients is greater than 0 (meaning if there is a max connection limit) then check if that has been reached TCPCloseSocket($iSock) ;It has been reached, close the new connection and continue back at the top of the loop ContinueLoop EndIf ReDim $Clients[$iSize + 1][4] ;There is room for a new connection, allocate space for it here $Clients[0][0] = $iSize ;Update the number of connected clients $Clients[$iSize][0] = $iSock ;Set the socket ID of the connection $Clients[$iSize][1] = SocketToIP($iSock, $Ws2_32) ;Set the IP Address the connection is from $Clients[$iSize][2] = TimerInit() ;Set the timestamp for the last known activity timer $Clients[$iSize][3] = "" ;Blank the recv buffer #EndRegion --> mycode WEnd _Service_ReportStatus($SERVICE_STOP_PENDING, $NO_ERROR, 1000) DllCallbackFree($tServiceMain) DllCallbackFree($tServiceCtrl) _Service_ReportStatus($SERVICE_STOPPED, $NO_ERROR, 0) DllClose($hAdvapi32_DLL) DllClose($hKernel32_DLL) Sleep(1000) ProcessClose(@AutoItPID) Return EndFunc ;==>_Main Can someone help me please?
×
×
  • Create New...