presence: fix endless publish/409 error loop at startup
commit0e7f5dfe8531b1dfc1397af9e0ea1c5500a1e161
authorStefan Becker <stefan.becker@nokia.com>
Thu, 25 Mar 2010 22:40:51 +0000 (26 00:40 +0200)
committerStefan Becker <stefan.becker@nokia.com>
Thu, 25 Mar 2010 22:40:51 +0000 (26 00:40 +0200)
tree4266ae2bf788438090eeeadb529af8a975fbf1f1
parent5722fc9660090bf1f0629c6e0c39a8777f9b2294
presence: fix endless publish/409 error loop at startup

As has also been noticed by other users in my company, it can sometimes happen
that SIPE gets stuck in a "busy" loop at startup, constantly re-sending the
same message which gets rejected by the server. This is especially nasty when
SIPE is running on a mobile device, like the N900, where it causes a huge drain
on the battery.

The loop happens when we receive a "409 Conflict" response from the server
under the following conditions:

   - initial publish, i.e. we include the "device" category
   - server sends us back a fault for category X
     (In all the cases I've studied category X was "device")
   - sip->our_publications does not contain category X
     (I'm not sure why this happens. This might be the root cause...)

I've circumvented the problem by adding a publication for the "lost" category
using the fault information provided by the server. When this happens you'll
see in the log messages like:

   sipe: added lost category 'device' key '<device><2625814930><2>'

I'm pretty sure this has something to do with improper de-registering when
Pidgin exits and SIPE doesn't have enough time to send out all messages. That
could leave incorrect information on the server which leads it to reject our
publication on the next login.
src/core/sipe.c