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

Question on Event loop and async support? #237

Open
nginxsantos opened this issue Aug 23, 2018 · 4 comments
Open

Question on Event loop and async support? #237

nginxsantos opened this issue Aug 23, 2018 · 4 comments

Comments

@nginxsantos
Copy link

Hi,
Can this run inside my application's event loop or it has to have its own event loop?
Also, does it support asynchronous handling
Thanks, santos

@davidmoreno
Copy link
Owner

Hi,

it should be possible to use through another event loop. Check poller_libev.c and poller_libevent.c.

Once a request handler is called it has to finish the processing of that request, so it may block your program if you dont use threads.

Do you refer to that as asynchronous handling or are you referring to something else?

Regards-

@alanswx
Copy link

alanswx commented May 13, 2019

I am working on putting this into MiSTer's game loop, and I need it to be called periodically from the main loop.

I separated onion_listen into three functions, a setup, poll, and cleanup. I had to make two versions of onion_poller_poll, one called: onion_poller_poll_once that get's rid of the while, and passes 0 in for epoll. I need to clean this up, and figure out how to test it. Do you think something like this would be a patch you would consider accepting? I think it is fairly clean. I am just a little confused about this path:

if (o->flags & O_ONE) {

@davidmoreno
Copy link
Owner

Hi,

of course I will consider merging!

About that if, there is one mode that only serves one request and returns from onion_listen, that's the branch for that mode. But actually it is not very tested. It was useful at the beginning but later was superseded by the poll mode.

@alanswx
Copy link

alanswx commented May 14, 2019

Sounds great. I will clean up my code and try to submit a pr. Thanks for the explanation of the if, that makes more sense now. I think I can pass some arguments to the polling function and not duplicate the code.

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