| 84 | { |
| 85 | SC_TRY_MSG(state == State::Stopping, "HttpAsyncServer::waitForStopToFinish requires stopping state"); |
| 86 | while (connections.getNumActiveConnections() > 0) |
| 87 | { |
| 88 | SC_TRY(eventLoop->runNoWait()); |
| 89 | } |
| 90 | while (not asyncServerAccept.isFree()) |
| 91 | { |
| 92 | SC_TRY(eventLoop->runNoWait()); |
| 93 | } |
| 94 | bool checkAgainAllClients; |
| 95 | do |
| 96 | { |
| 97 | checkAgainAllClients = false; |
| 98 | for (size_t idx = 0; idx < connections.getNumTotalConnections(); ++idx) |
| 99 | { |
| 100 | HttpConnection& client = static_cast<HttpConnection&>(connections.getConnectionAt(idx)); |
| 101 | while (not client.readableSocketStream.request.isFree() or not client.writableSocketStream.request.isFree()) |
| 102 | { |
| 103 | SC_TRY(eventLoop->runNoWait()); |
| 104 | checkAgainAllClients = true; |
| 105 | } |
| 106 | SC_HTTP_ASSERT_RELEASE(client.pipeline.unpipe()); |
| 107 | } |
| 108 | } while (checkAgainAllClients); |
| 109 | state = State::Stopped; |
| 110 | return Result(true); |
| 111 | } |
| 112 | |
| 113 | struct HttpAsyncServer::EventDataListener |
| 114 | { |
| 115 | HttpAsyncServer& pself; |
| 116 | HttpConnection& client; |
| 117 | |