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

Forced service with custom epoll loop #3160

Open
alex7691076 opened this issue Jun 1, 2024 · 1 comment
Open

Forced service with custom epoll loop #3160

alex7691076 opened this issue Jun 1, 2024 · 1 comment

Comments

@alex7691076
Copy link

Hi @lws-team,

I am trying to integrate libwebsockets into a project with a custom io_uring+epoll loop... and mostly managed to connect the pieces similar to minimal-http-server-eventlib-custom example from the repository.

I am registering libwebsockets fds, with my epoll, and then use lws_service_fd() to service those fds on set events in individual callbacks.

It seems like I ran into a problem of "forced service" as mentioned in https://github.com/warmcat/libwebsockets/blob/v4.3-stable/READMEs/README.coding.md (@section extpoll).

If I understood correctly, I have to check if lws_service_adjust_timeout() gives me a 0, then there is a "forced service" needed and I should then call lws_service_tsi() with a timeout of -1 ... but the eventlib-custom example does not seem to be doing that explicitly.

Can you please clarify whether a call to lws_service_tsi(context, -1, 0) is needed? or why it is missing from the mentioned example?

Thanks.

-- Alexey

@lws-team
Copy link
Member

lws-team commented Jun 1, 2024

I think forced service is handled internally for a while.

Originally there was an explicit service loop needed in user code because we went around it after every event. But for a while that has been changed to stay in the service call until we exit the event loop wholesale, this is aligned to how real event libs work, you start the event loop and don't come back from that until the loop ends, you just get callbacks from the events.

So there's now a loop in lws_service_tsi() with calculated max waits considering suls, it knows about forced service (essentially more work to do, but there won't be any more fd events to trigger it) and just goes again immediately.

External poll is very old and should have been deprecated years ago, it's disabled by default for good reasons. Custom event lib is the modern way that is much better.

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

2 participants