MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / stop

Method stop

Source/Http/HttpServer.cpp:334–356  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

332 }
333
334 void stop() {
335 bool needStop = false;
336 {
337 std::lock_guard<std::mutex> guard(_shutdownLock);
338 needStop = !_stopped;
339 }
340 if (needStop) {
341 auto connections = snapshotConnections();
342 for (const auto& connection : connections) {
343 if (!connection) continue;
344 std::lock_guard<std::mutex> guard(connection->lock);
345 if (connection->webSocket && connection->webSocket->is_open()) {
346 connection->webSocket->close(httplib::ws::CloseStatus::GoingAway, "shutting down"s);
347 }
348 }
349 _server.stop();
350 std::unique_lock<std::mutex> lock(_shutdownLock);
351 _waitForShutdown.wait(lock, [this]() {
352 return _stopped;
353 });
354 }
355 LogHandler -= std::make_pair(this, &WebSocketServer::sendLog);
356 }
357
358private:
359 std::vector<ConnectionPtr> snapshotConnections() const {

Callers

nothing calls this directly

Calls 5

make_pairFunction · 0.85
closeMethod · 0.65
stopMethod · 0.65
is_openMethod · 0.45
waitMethod · 0.45

Tested by

no test coverage detected