potential fix for #677

pull/1385/head
AlexandreRouma 2024-04-08 16:59:05 +02:00
rodzic e1c48e9a1f
commit 07eebd7018
2 zmienionych plików z 20 dodań i 3 usunięć

Wyświetl plik

@ -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;

Wyświetl plik

@ -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);