Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added wait timeout on server start #889

Closed
Closed
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
8 changes: 4 additions & 4 deletions include/crow/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -689,18 +689,18 @@ namespace crow
}

/// \brief Wait until the server has properly started
void wait_for_server_start()
void wait_for_server_start(std::chrono::milliseconds wait_for_milliseconds = std::chrono::milliseconds(0))
{
{
std::unique_lock<std::mutex> lock(start_mutex_);
while (!server_started_)
cv_started_.wait(lock);
cv_started_.wait_for(lock,wait_for_milliseconds);
}
if (server_)
server_->wait_for_start();
server_->wait_for_start(wait_for_milliseconds);
#ifdef CROW_ENABLE_SSL
else if (ssl_server_)
ssl_server_->wait_for_start();
ssl_server_->wait_for_start(wait_for_milliseconds);
#endif
}

Expand Down
4 changes: 2 additions & 2 deletions include/crow/http_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,11 @@ namespace crow // NOTE: Already documented in "crow/app.h"
}

/// Wait until the server has properly started
void wait_for_start()
void wait_for_start(std::chrono::milliseconds wait_for_milliseconds)
{
std::unique_lock<std::mutex> lock(start_mutex_);
while (!server_started_)
cv_started_.wait(lock);
cv_started_.wait_for(lock,wait_for_milliseconds);
}

void signal_clear()
Expand Down
Loading