Hi Sergey, you said: "Blocking or otherwise long-running operations must be moved to dedicated threads. A callback that needs to get a result of long-running operation should schedule it, return MG_MORE -- and not block mongoose. Mongoose will send MG_POLLs to that connection, where callback may decide to complete the reply, or, alternatively, other thread could mg_ wakeup_server_ex() to push the result of the long-running operation to the respective connection."
Does this mean that the two approaches you describe are mutually exclusive? I.e., we got our product working again after upgrading to 5.4 by refactoring it to use the mg_wakeup_server_ex() approach you described above. However, we find that when we also return MG_MORE and handle MG_POLL, our app just hangs. But when we return MG_TRUE, start a new thread to do the work, then send the result back to the proper connection using mg_wakeup_server_ex(), then everything seems to work fine. This is a little confusing because we thought if the initial user callback function returned MG_TRUE, that would tell mongoose that we are done sending the response and it can close the connection. This does not correspond with what we seem to be seeing though. Even though we return MG_TRUE after starting the worker thread, later when we call mg_wakeup_server_ex() from that thread, the connection pointer we need to send the response to is still valid and everything seems to work. However when we return MG_MORE and handle MG_POLL we can't get things to work with the mg_wakeup_server_ex() approach. Hope this makes sense. Are we doing things properly? Thanks for any insight you have to offer. -Scott On Friday, August 8, 2014 10:44:35 AM UTC-6, Sergey Lyubka wrote: > > Mongoose releases, including 5.4, are here: > https://github.com/cesanta/mongoose/releases > > Please read the docs as well, many things are explained there: > http://cesanta.com/docs/Embed.shtml > http://cesanta.com/docs/API.shtml > > > On Fri, Aug 8, 2014 at 5:32 PM, Scott Ellis <[email protected] > <javascript:>> wrote: > >> You said "another thread could mg_wakeup_server_ex() to push the result >> of the long-running operation to the respective connection" >> >> I am finding that mg_wakeup_server_ex() does not exist in mongoose 5.3. >> >> I am only able to get source for 5.3. Is this function only in 5.4? Can I >> have access to that source to try it out? >> >> I tried calling mg_wakeup_server() (which does exist in 5.3) from a long >> running user callback in another thread, but find that the mg_connection >> structure has gone bad when I try to write the response. >> >> Thanks, >> Scott >> >> On Friday, August 8, 2014 9:23:05 AM UTC-6, Scott Ellis wrote: >>> >>> I think so. Thanks a lot for the detailed response. Will see what I can >>> do with this information. >>> Thanks >>> -Scott >> >> -- >> 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] <javascript:>. >> To post to this group, send email to [email protected] >> <javascript:>. >> Visit this group at http://groups.google.com/group/mongoose-users. >> For more options, visit https://groups.google.com/d/optout. >> > > -- 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.
