diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2012-09-12 10:41:27 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-09-14 07:05:25 +0200 |
commit | 815decb03474754a56e7572a2823ce438a81023b (patch) | |
tree | 620c5cb1f02530d95e5178b4e16007bf33c0473b /src/mm-sms-list.c | |
parent | 8cbf3b7826ccf794431d37e449724caaf0f4206b (diff) |
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
Diffstat (limited to 'src/mm-sms-list.c')
-rw-r--r-- | src/mm-sms-list.c | 26 |
1 files changed, 22 insertions, 4 deletions
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 @@ -288,6 +288,25 @@ take_multipart (MMSmsList *self, } 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, MMSmsState state, @@ -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, |