Address another Milliseconds misusage (similar to #124)

pull/135/head
Oleg Nenashev 2016-11-26 23:18:03 +01:00
parent dfafc2790d
commit 2a07f6af5d
1 changed files with 14 additions and 1 deletions

View File

@ -473,9 +473,22 @@ namespace winsw
private void SignalShutdownPending()
{
int effectiveWaitHint;
if (_descriptor.WaitHint.TotalMilliseconds > Int32.MaxValue)
{
Log.Warn("The requested WaitHint value (" + _descriptor.WaitHint.TotalMilliseconds + " ms) is greater that the max value " +
Int32.MaxValue + ". The value will be truncated");
effectiveWaitHint = Int32.MaxValue;
}
else
{
effectiveWaitHint = (int)_descriptor.WaitHint.TotalMilliseconds;
}
IntPtr handle = ServiceHandle;
_wrapperServiceStatus.checkPoint++;
_wrapperServiceStatus.waitHint = _descriptor.WaitHint.Milliseconds;
_wrapperServiceStatus.waitHint = effectiveWaitHint;
// WriteEvent("SignalShutdownPending " + wrapperServiceStatus.checkPoint + ":" + wrapperServiceStatus.waitHint);
_wrapperServiceStatus.currentState = (int)State.SERVICE_STOP_PENDING;
Advapi32.SetServiceStatus(handle, ref _wrapperServiceStatus);