server : fix crash in Debug on macOS (I have no idea why this fixes it!?)

This commit is contained in:
Georgi Gerganov 2023-10-22 16:55:40 +03:00
parent 197a0a9e23
commit ef18f4d579
No known key found for this signature in database
GPG Key ID: 449E073F9DC10735

View File

@ -2440,7 +2440,21 @@ int main(int argc, char **argv)
{"hostname", sparams.hostname}, {"hostname", sparams.hostname},
{"port", sparams.port}, {"port", sparams.port},
}); });
std::thread t([&llama]()
// run the HTTP server in a thread - see comment below
std::thread t([&]()
{
if (!svr.listen_after_bind())
{
return 1;
}
return 0;
});
// GG: if I put the main loop inside a thread, it crashes on the first request when build in Debug!?
// "Bus error: 10" - this is on macOS, it does not crash on Linux
//std::thread t2([&]()
{ {
bool running = true; bool running = true;
while (running) while (running)
@ -2448,12 +2462,9 @@ int main(int argc, char **argv)
running = llama.update_slots(); running = llama.update_slots();
} }
} }
); //);
if (!svr.listen_after_bind()) t.join();
{
return 1;
}
llama_backend_free(); llama_backend_free();
return 0; return 0;