From c4869c7fcbf0a8ad253544aa0743d04159bb2f55 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 10 May 2011 19:09:49 +0100 Subject: [PATCH] tp_base_connection_change_status: delay side-effects until all preconditions are checked If the caller makes an invalid state change, we shouldn't allow the status to be updated, for instance from DISCONNECTED to CONNECTED if success and failure race with each other and failure wins, as seen in fd.o #37078; we should just emit the critical warning and leave it DISCONNECTED. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=37079 --- telepathy-glib/base-connection.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/telepathy-glib/base-connection.c b/telepathy-glib/base-connection.c index 8e5e076..ad05abb 100644 --- a/telepathy-glib/base-connection.c +++ b/telepathy-glib/base-connection.c @@ -2875,7 +2875,6 @@ tp_base_connection_change_status (TpBaseConnection *self, } prev_status = self->status; - self->status = status; /* make appropriate assertions about our state */ switch (status) @@ -2902,6 +2901,10 @@ tp_base_connection_change_status (TpBaseConnection *self, return; } + /* now that we've finished return_if_fail'ing, we can start to make + * the actual changes */ + self->status = status; + /* ref self in case user callbacks unref us */ g_object_ref (self); -- 1.7.5.1