Extend windows startup timeout

If wintun fails it seems to take about 15s, so extend the startup
timeout so that it can fail gracefully (and let us clean up before
exiting).

Also refactors the timeouts to chrono constants.
pull/2045/head
Jason Rhinelander 2 years ago committed by Jeff Becker
parent 71bea4f0fc
commit 31c312ad41
No known key found for this signature in database
GPG Key ID: 025C02EE3A092F2D

@ -1,4 +1,5 @@
#include <windows.h>
#include <chrono>
#include <llarp.hpp>
#include <llarp/util/logging.hpp>
#include "service_manager.hpp"
@ -90,7 +91,15 @@ namespace llarp::sys
_status.dwWin32ExitCode = NO_ERROR;
_status.dwCurrentState = new_state;
_status.dwControlsAccepted = st == ServiceState::Running ? SERVICE_ACCEPT_STOP : 0;
// tell windows it takes 5s at most to start or stop
_status.dwWaitHint =
std::chrono::milliseconds{
st == ServiceState::Starting ? StartupTimeout
: st == ServiceState::Stopping ? StopTimeout
: 0s}
.count();
// dwCheckPoint gets incremented during a start/stop to tell windows "we're still
// starting/stopping" and to reset its must-be-hung timer. We increment it here so that this
// can be called multiple times to tells Windows something is happening.
if (st == ServiceState::Starting or st == ServiceState::Stopping)
_status.dwCheckPoint++;
else

@ -1,5 +1,8 @@
#pragma once
#include <chrono>
#include <llarp/util/service_manager.hpp>
#include <llarp/util/types.hpp>
namespace llarp::sys
{
@ -10,6 +13,14 @@ namespace llarp::sys
public:
SERVICE_STATUS_HANDLE handle;
// How long we tell Windows to give us to startup before assuming we have stalled/hung. The
// biggest potential time here is wintun, which if it is going to fail appears to take around
// 15s before doing so.
static constexpr auto StartupTimeout = 17s;
// How long we tell Windows to give us to fully stop before killing us.
static constexpr auto StopTimeout = 5s;
SVC_Manager();
void

Loading…
Cancel
Save