Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Networking/WebSockets/c4WebSocket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,10 @@ namespace litecore::repl {
catchAndWarn() return false;
}

bool C4WebSocket::waitForTLSHandshake() {
bool C4WebSocket::waitForTLSHandshake(unsigned timeoutSecs) {
unique_lock lock(_mutex);
_tlsHandshakeCondition.wait(lock, [this] { return _peerCertData != nullslice || _closed; });
_tlsHandshakeCondition.wait_for(lock, chrono::seconds(timeoutSecs),
[this] { return _peerCertData != nullslice || _closed; });
return _peerCertData != nullslice && !_closed;
}

Expand Down
2 changes: 1 addition & 1 deletion Networking/WebSockets/c4WebSocket.hh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace litecore::repl {
void closeWithException();

/** Blocks until the TLS handshake completes or the socket closes. Returns true on success. */
[[nodiscard]] bool waitForTLSHandshake();
[[nodiscard]] bool waitForTLSHandshake(unsigned timeoutSecs);

// WebSocket public API:
void connect() override;
Expand Down
Loading