Refactor GStaticPrivate accessors to facilitate protecting them with locks
authorSimon McVittie <simon.mcvittie@collabora.co.uk>
Tue, 24 May 2011 15:23:02 +0000 (16:23 +0100)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 28 May 2011 14:00:40 +0000 (10:00 -0400)
commit83f1b12388fc36128dac84729f433eff8183ff45
tree0d19d0b0391c98d3a73d2010868131ba1e418cd2
parentb05f0b351c46a8f97bf7e9d62f5dd4074ca78486
Refactor GStaticPrivate accessors to facilitate protecting them with locks

* g_static_private_get: have a single entry and exit

* g_static_private_set: delay creation of GArray so the whole tail of
  the function can be under the private_data lock without risking
  deadlock with the g_thread lock; call the destructor last, after
  we could have unlocked

* g_static_private_free: choose next thread in list before accessing
  private_data, to keep all accesses together

* g_thread_cleanup: steal private_data first, then work exclusively with
  the stolen array (which doesn't need to be under a lock any more)

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=642026
Bug-NB: NB#257512
glib/gthread.c