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

so on null event handler #871

Closed
liquidatom opened this issue Nov 10, 2017 · 1 comment
Closed

so on null event handler #871

liquidatom opened this issue Nov 10, 2017 · 1 comment

Comments

@liquidatom
Copy link

liquidatom commented Nov 10, 2017

i'm trying to handler http request on single endpoint, so i specified handler like this:
mg_bind(m_mgr, port, nullptr); // i don't need handle other requests
mg_register_http_endpoint(m_conn, "/path", pathHandler);


mongoose fail with stack overflow when mg_call try to call default handler for HTTP mg_http_handler and so on
mg_call:
if (ev_handler == NULL) {
/*
* If protocol handler is specified, call it. Otherwise, call user-specified
* event handler.
*/
ev_handler = nc->proto_handler ? nc->proto_handler : nc->handler;
}


ev_handler(nc, ev, ev_data MG_UD_ARG(user_data)); // calling mg_http_handler

and in mg_http_handler we have:
mg_call(nc, nc->handler, nc->user_data, ev, ev_data);


not sure how it can be correctly resolved, but it seems strange that mg_http_handler can call parent function(mg_call)

@dimonomid
Copy link
Contributor

The handler for mg_bind is required, don't pass NULL there. Provide an empty implementation of the handler at least.

We should fix mg_bind to return NULL if passed a NULL handler though.

@rojer rojer closed this as completed Feb 2, 2018
cesantabot pushed a commit that referenced this issue Feb 2, 2018
Before it resulted in an endless recursion.

Resolves #871

CL: Mongoose Web Server: Fail if passed a NULL handler to `mg_bind` or `mg_bind_opt`.

PUBLISHED_FROM=376e5d330a643fa530f6a27a422a1500f986c721
cesantabot pushed a commit to cesanta/mongoose-os that referenced this issue Feb 2, 2018
Before it resulted in an endless recursion.

Resolves cesanta/mongoose#871

CL: Mongoose Web Server: Fail if passed a NULL handler to `mg_bind` or `mg_bind_opt`.

PUBLISHED_FROM=376e5d330a643fa530f6a27a422a1500f986c721
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