From 815decb03474754a56e7572a2823ce438a81023b Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Wed, 12 Sep 2012 10:41:27 +0200 Subject: broadband-modem: properly avoid duplicate CMTI indications We will look for the part being notified in the CMTI indication directly in the list of processed parts; and if we have it there already we won't re-process it. Still, we may get several CMTI indications for the same part one after the other, so it may still happen that the second CMTI comes *before* we have parsed and created the part in the SMS list. For that case, the SMS list will reject taking the part if there is already a part with the same storage+index already processed. This fix removes the `known_sms_parts' hash table, which was being handled incorrectly. This should fix https://bugzilla.gnome.org/show_bug.cgi?id=675175 --- src/mm-sms-list.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'src/mm-sms-list.c') diff --git a/src/mm-sms-list.c b/src/mm-sms-list.c index 5bb0e924..9afe96f6 100644 --- a/src/mm-sms-list.c +++ b/src/mm-sms-list.c @@ -287,6 +287,25 @@ take_multipart (MMSmsList *self, return TRUE; } +gboolean +mm_sms_list_has_part (MMSmsList *self, + MMSmsStorage storage, + guint index) +{ + PartIndexAndStorage ctx; + + if (storage == MM_SMS_STORAGE_UNKNOWN || + index == SMS_PART_INVALID_INDEX) + return FALSE; + + ctx.part_index = index; + ctx.storage = storage; + + return !!g_list_find_custom (self->priv->list, + &ctx, + (GCompareFunc)cmp_sms_by_part_index_and_storage); +} + gboolean mm_sms_list_take_part (MMSmsList *self, MMSmsPart *part, @@ -300,10 +319,9 @@ mm_sms_list_take_part (MMSmsList *self, ctx.storage = storage; /* Ensure we don't have already taken a part with the same index */ - if (mm_sms_part_get_index (part) != SMS_PART_INVALID_INDEX && - g_list_find_custom (self->priv->list, - &ctx, - (GCompareFunc)cmp_sms_by_part_index_and_storage)) { + if (mm_sms_list_has_part (self, + storage, + mm_sms_part_get_index (part))) { g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, -- cgit v1.2.3-70-g09d2