purple: switch to deferred destruction approach
commit8ac81dc5d7c0b764a476b302d744b34d79b38b77
authorStefan Becker <chemobejk@gmail.com>
Thu, 11 Apr 2013 18:21:22 +0000 (11 21:21 +0300)
committerStefan Becker <chemobejk@gmail.com>
Thu, 11 Apr 2013 18:34:25 +0000 (11 21:34 +0300)
tree5e649f82b3ff7480fd560fca542627f573f14074
parent390ec2a05a33592ebde133f343d35ea8ae4ba6e6
purple: switch to deferred destruction approach

Over the years we have tried to fix various crashes by adding
PURPLE_CONNECTION_IS_VALID() calls here and there. But still SIPE keeps
crashing in corner cases.

Take a page from the telepathy backend development and switch DNS Query
& transport descruction to a deferred descruction approach:

 - in constructor:
   * set is_valid = TRUE
   * add data structure to list of queries/transports
 - all callbacks from libpurple now check is_valid before continuing
 - in destructor:
   * remove data structure from list of queries/transports
   * closes all associated resources (as before)
   * set is_valid = FALSE
   * schedule deferred descructor with g_idle_add()
 - in deferred detructor:
   * all (possible) pending events have been processed already
   * it is now safe to call g_free() on the data structure

I have tried to crash Pidgin by randomly disabling the account during
various phases of the connection setup, but I can't get it to crash
anymore.
ChangeLog
src/purple/purple-dnsquery.c
src/purple/purple-plugin.c
src/purple/purple-private.h
src/purple/purple-transport.c