On Mon, Aug 25, 2014 at 4:36 PM, Scott Ellis <[email protected]> wrote:
> 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. > My guess that it works because the connection is kept alive, and in fact not serving anything but waiting for the request. You're pushing data to the client without client requesting anything. -- 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.
