Hi,
I have the requirement that when client call comes, mongoose event handler
should asynchronously read data from other node (a callback fn is provided
as shown below) and when the callback fn returns with data, mongoose should
return response to the client. I am a little unsure how to maintain
connection alive across threads (main thread and callback threads) and how
to correctly close the connection at the end of callback fn. Can somebody
also explain MG_MORE a little more ?
I am thinking about the following flow. Please let me know
static int ev_handler(struct mg_connection *conn, enum mg_event ev)
{
if (ev == MG_REQUEST) {
async_read_from_other_node(conn);
return MG_MORE; // Is it right??? I
do not want to close connection this time and want callback_fn() thread to
close it.
} else {
return MG_TRUE;
}
async_read_from_other_node(struct mg_connection *conn)
{
callback_arg = conn;
initiate_async_read_from_other_node(callback_fn, callback_arg);
return;
}
callback_fn(void *data, void *callback_arg)
{
struct mg_connection *conn = callback_arg;
// now from here it should return back with response to the client
// how to close the connection from here???
return MG_TRUE;
}
--
You received this message because you are subscribed to the Google Groups
"mongoose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mongoose-users.
For more options, visit https://groups.google.com/d/optout.