]> git.0d.be Git - empathy.git/commitdiff
Fix a theoretical race listing pending messages
authorWill Thompson <will.thompson@collabora.co.uk>
Sat, 25 Apr 2009 09:07:31 +0000 (10:07 +0100)
committerWill Thompson <will.thompson@collabora.co.uk>
Sat, 25 Apr 2009 09:07:31 +0000 (10:07 +0100)
If you call ListPendingMessages before connecting to Received, the
following could theoretically occur:

    Empathy --- ListPendingMessages --> CM
    Empathy <-- LPM returns         --- CM
                                 <----- CM -----> Received
    Empathy connects to Received

and thus you could miss a message. Connecting to Received before calling
ListPendingMessages avoids this (mostly theoretical) bug.

Signed-off-by: Will Thompson <will.thompson@collabora.co.uk>
libempathy/empathy-tp-chat.c

index 54e08d07139cebb04b921338a88dd5ab936349e5..2f951e04053baafab9ddd8aaba085019c00a932e 100644 (file)
@@ -753,6 +753,10 @@ tp_chat_check_if_ready (EmpathyTpChat *chat)
 
        DEBUG ("Ready!");
 
+       tp_cli_channel_type_text_connect_to_received (priv->channel,
+                                                     tp_chat_received_cb,
+                                                     NULL, NULL,
+                                                     G_OBJECT (chat), NULL);
        priv->listing_pending_messages = TRUE;
        tp_cli_channel_type_text_call_list_pending_messages (priv->channel, -1,
                                                             FALSE,
@@ -760,10 +764,6 @@ tp_chat_check_if_ready (EmpathyTpChat *chat)
                                                             NULL, NULL,
                                                             G_OBJECT (chat));
 
-       tp_cli_channel_type_text_connect_to_received (priv->channel,
-                                                     tp_chat_received_cb,
-                                                     NULL, NULL,
-                                                     G_OBJECT (chat), NULL);
        tp_cli_channel_type_text_connect_to_sent (priv->channel,
                                                  tp_chat_sent_cb,
                                                  NULL, NULL,