Thanks Alexander!

Honestly, I don't particularly like that CONN_LONG_RUNNING thing.
I think a cleaner solution would be to go with event-based approach:
use single event handler and send AUTH, START_REQUEST, END_REQUEST, POLL
events to the handler.

POLL would be sent on each mg_poll_server() iteration, letting
any connection including long-running connections do it's job.

What do you think about event-based approach?



On Wed, Feb 19, 2014 at 4:45 PM, Alexander Björck <[email protected]> wrote:

> A related issue appeared;
>
> I'm using an "idle" websocket to wait for server side data to be sent at
> any given time. I find the same kind of issue here, that the client must
> wait for something else to happen on the socket before the handler is
> called.
> I made a patch that seems to work, but I don't know how correct/complete
> this is:
> (compared to d5004cb7eb181237db3f3b903326ece772049e6d)
>
> diff --git a/mongoose.c b/mongoose.c
> index 11d02c8..aa0a2ac 100644
> --- a/mongoose.c
> +++ b/mongoose.c
> @@ -2478,8 +2478,11 @@ static int deliver_websocket_frame(struct
> connection *conn) {
>      }
>
>      // Call the handler and remove frame from the iobuf
> -    if (conn->server->request_handler(&conn->mg_conn) == MG_CLIENT_CLOSE)
> {
> -      conn->ns_conn->flags |= NSF_FINISHED_SENDING_DATA;
> +    int ret = conn->server->request_handler(&conn->mg_conn);
> +    if (ret == MG_CLIENT_CLOSE) {
> +      conn->flags |= CONN_SPOOL_DONE;
> +    } else if (ret == MG_REQUEST_CALL_AGAIN) {
> +        conn->flags |= CONN_LONG_RUNNING;
>      }
>      iobuf_remove(&conn->ns_conn->recv_iobuf, frame_len);
>    }
>
>
>
> On Friday, 17 January 2014 20:25:39 UTC+1, Alexander Björck wrote:
>>
>> Thanks for the quick work :)
>>
>>
>> On Fri, Jan 17, 2014 at 5:38 PM, Sergey Lyubka <[email protected]> wrote:
>>
>>> On Fri, Jan 17, 2014 at 4:33 PM, <[email protected]> wrote:
>>>
>>>> Yes, but my handler would not be called, unless some other socket has
>>>> reads/writes, anyway?
>>>>
>>>
>>> Got it, you're right.
>>> I've moved handler call to make it trigger regardless: https://github.
>>> com/cesanta/mongoose/commit/82ad9a073adee26cfb340be935b79e6c4ade3113
>>>
>>>
>>>  --
>>> You received this message because you are subscribed to a topic in the
>>> Google Groups "mongoose-users" group.
>>> To unsubscribe from this topic, visit https://groups.google.com/d/
>>> topic/mongoose-users/0vxElWO7B5w/unsubscribe.
>>> To unsubscribe from this group and all its topics, 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/groups/opt_out.
>>>
>>
>>  --
> 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/groups/opt_out.
>

-- 
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/groups/opt_out.

Reply via email to