| 100 | } |
| 101 | |
| 102 | void DebuggerService::doStart(int attemptNumber) { |
| 103 | if (_tcpServer != nullptr) { |
| 104 | return; |
| 105 | } |
| 106 | |
| 107 | if (!_started) { |
| 108 | return; |
| 109 | } |
| 110 | |
| 111 | _tcpServer = TCPServer::create(_debuggerPort, this); |
| 112 | auto result = _tcpServer->start(); |
| 113 | if (result) { |
| 114 | VALDI_INFO(*_logger, "Started Valdi debugger service on {}", _debuggerPort); |
| 115 | } else { |
| 116 | [[maybe_unused]] auto attemptLogType = attemptNumber > 3 ? Valdi::LogTypeDebug : Valdi::LogTypeWarn; |
| 117 | VALDI_LOG(*_logger, |
| 118 | attemptLogType, |
| 119 | "Failed to start Valdi debugger service (attempt #{}): {}", |
| 120 | attemptNumber, |
| 121 | result.error()); |
| 122 | _tcpServer = nullptr; |
| 123 | |
| 124 | long retryDelay = attemptNumber < 5 ? attemptNumber : 5; |
| 125 | _dispatchQueue->asyncAfter([this, attemptNumber]() { this->doStart(attemptNumber + 1); }, |
| 126 | std::chrono::seconds(retryDelay)); |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | void DebuggerService::stop() { |
| 131 | _dispatchQueue->async([this]() { |
no test coverage detected