Re: Longpoll with Libsoup
- From: "Mark Delany" <x8w alpha emu st>
- To: libsoup-list gnome org
- Subject: Re: Longpoll with Libsoup
- Date: 14 May 2012 08:56:49 +0000
>I have a similar question to Mark's post about longpolling a few weeks
>ago. I have a system that is doing lonpolling. However, I would like to
>stop various backend work when the client disconnects. I haven't found a
>way to get an event upon the client disconnecting.
>It appears based on the code I've read that "disconnect" would be
>unlikely to fire while the SoupMessage's IO is paused. (That is why I
>tried the route of polling the FD myself with a custom GSource and
>g_source_add_poll().
I think you need to distinguish between connected vs paused. My
definition of paused is that no request came in within 'x' seconds. If
that is your definition, then libsoup/glib provides pretty much all
the mechanisms you need.
If you want to define paused as meaning no bytes within 'y' seconds,
that's stepping more outside libsoup and requires the polling stuff
you refer to.
Here's what I did:
1. All new connections are stored in a hash container. I did this from
the request_started signal.
2. All disconnected sessions are removed from the hash container. I
did this from the request_aborted and request_finished signals.
3. Any time a complete inbound request is presented to the request
handler, the current time is put in the "last_request_time" value
associated with the connection entry in the hash container.
4. A timer event wakes every 30 seconds or so and iterated over the
hash container to cancel connections that have a "last_request_time"
value that is too old.
The only non-standard thing in all of this is that the "cancel
inactive connections" mechanism is a bit of a hack. The shutdown()
technique mentioned by the libsoup author on this thread is what I
have adopted until their is a formal cancel mechanism.
Mark.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]