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

Event loop not ending for thread #109

Open
dreadsfun opened this issue May 8, 2022 · 2 comments
Open

Event loop not ending for thread #109

dreadsfun opened this issue May 8, 2022 · 2 comments
Assignees

Comments

@dreadsfun
Copy link

dreadsfun commented May 8, 2022

Hi

Using WSL with Ubuntu, GCC 11.1.0 and CMake to build my project with lithium I have the following issue
In my main I have:

http_api root;
lemw::api::auth auth(root);
http_serve(root, 8080);

auth registers an empty post handler on /auth/login

void auth::login(http_request& request, http_response& response) {
  response.write_json(s::success = true);
}

The server starts fine, and if I don't call the login endpoint, it also stops fine with ctrl+C, (sending SIGTERM):

Starting lithium::http_server on port 8080
^CThe server will shutdown...
END OF EVENT LOOP
END OF EVENT LOOP
END OF EVENT LOOP
END OF EVENT LOOP
END OF EVENT LOOP
END OF EVENT LOOP

However, If I call the login endpoint before trying to exit, one of the threads (the one that handled the request) gets stuck:

Starting lithium::http_server on port 8080
^CThe server will shutdown...
END OF EVENT LOOP
END OF EVENT LOOP
END OF EVENT LOOP
END OF EVENT LOOP
END OF EVENT LOOP
Killed

From the 6 threads only 5 reaches end of event loop, then it only stops with sending SIGKILL to the main thread
Without the kill signal, the server actually continues to serve requests with that one thread:

(Here I have spdlog set up to see what's happening, but the same thing happens without any extra code)

[01:38:45] [I] [T9653] Start logging
Starting lithium::http_server on port 8080
[01:38:51] [D] [T9664] login request username password
^CThe server will shutdown...
END OF EVENT LOOP
END OF EVENT LOOP
END OF EVENT LOOP
END OF EVENT LOOP
END OF EVENT LOOP
[01:40:29] [D] [T9664] login request username password
[01:40:33] [D] [T9664] login request username password
^CThe server will shutdown...
[01:43:22] [D] [T9664] login request username password
^CThe server will shutdown...
^CThe server will shutdown...
^CThe server will shutdown...
Killed

What could be the reason for this? Am I missing something to properly shut the server down?

Any help or suggestion is greatly appreciated
Thank you in advance!

@matt-42
Copy link
Owner

matt-42 commented May 9, 2022

Thanks for the report. I saw this problem on linux too. I'll have a look.

@matt-42 matt-42 self-assigned this May 9, 2022
@yzaimoglu
Copy link

Any progress?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants