potential fix for #677

This commit is contained in:
AlexandreRouma 2024-04-08 16:59:05 +02:00
parent e1c48e9a1f
commit 07eebd7018
2 changed files with 20 additions and 3 deletions

View File

@ -42,8 +42,20 @@ namespace server {
// Ask for a UI
int res = getUI();
if (res == -1) { throw std::runtime_error("Timed out"); }
else if (res == -2) { throw std::runtime_error("Server busy"); }
if (res < 0) {
// Close client
close();
// Throw error
switch (res) {
case CONN_ERR_TIMEOUT:
throw std::runtime_error("Timed out");
case CONN_ERR_BUSY:
throw std::runtime_error("Server busy");
default:
throw std::runtime_error("Unknown error");
}
}
}
Client::~Client() {
@ -234,7 +246,7 @@ namespace server {
else {
if (!serverBusy) { flog::error("Timeout out after asking for UI"); };
waiter->handled();
return serverBusy ? -2 : -1;
return serverBusy ? CONN_ERR_BUSY : CONN_ERR_TIMEOUT;
}
waiter->handled();
return 0;

View File

@ -71,6 +71,11 @@ namespace server {
std::mutex handledMtx;
};
enum ConnectionError {
CONN_ERR_TIMEOUT = -1,
CONN_ERR_BUSY = -2
};
class Client {
public:
Client(std::shared_ptr<net::Socket> sock, dsp::stream<dsp::complex_t>* out);