* [PATCH] Change order of freeing contacts data in send_pull_part
@ 2011-03-11 10:24 Radoslaw Jablonski
2011-03-11 15:46 ` Radoslaw Jablonski
0 siblings, 1 reply; 2+ messages in thread
From: Radoslaw Jablonski @ 2011-03-11 10:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Radoslaw Jablonski
Moved freeing data->contacts before asynchronous data sending
is triggered via data->cb callback.
This data is no longer needed anyway after vcards are generated
and freeing it later may cause race condition (because freeing
this data need to be handled also in phonebook_req_finalize to
avoid memory leaks when client disconnects in the middle of
retrieving contacts from db).
---
plugins/phonebook-tracker.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/plugins/phonebook-tracker.c b/plugins/phonebook-tracker.c
index 2fced7a..f241cb4 100644
--- a/plugins/phonebook-tracker.c
+++ b/plugins/phonebook-tracker.c
@@ -1576,13 +1576,16 @@ static void send_pull_part(struct phonebook_data *data,
const struct apparam_field *params, gboolean lastpart)
{
GString *vcards;
+ int amount;
DBG("");
vcards = gen_vcards(data->contacts, params);
- data->cb(vcards->str, vcards->len, g_slist_length(data->contacts),
- data->newmissedcalls, lastpart, data->user_data);
-
+ amount = g_slist_length(data->contacts);
free_data_contacts(data);
+
+ data->cb(vcards->str, vcards->len, amount, data->newmissedcalls,
+ lastpart, data->user_data);
+
g_string_free(vcards, TRUE);
}
--
1.7.0.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Change order of freeing contacts data in send_pull_part
2011-03-11 10:24 [PATCH] Change order of freeing contacts data in send_pull_part Radoslaw Jablonski
@ 2011-03-11 15:46 ` Radoslaw Jablonski
0 siblings, 0 replies; 2+ messages in thread
From: Radoslaw Jablonski @ 2011-03-11 15:46 UTC (permalink / raw)
To: Radoslaw Jablonski; +Cc: linux-bluetooth@vger.kernel.org
Hi,
On 03/11/2011 12:24 PM, Radoslaw Jablonski wrote:
> Moved freeing data->contacts before asynchronous data sending
> is triggered via data->cb callback.
> This data is no longer needed anyway after vcards are generated
> and freeing it later may cause race condition (because freeing
> this data need to be handled also in phonebook_req_finalize to
> avoid memory leaks when client disconnects in the middle of
> retrieving contacts from db).
> ---
> plugins/phonebook-tracker.c | 9 ++++++---
> 1 files changed, 6 insertions(+), 3 deletions(-)
>
Please ignore this patch - these changes are not needed in
current architecture (based on offline discussion with Johan).
BR,
Radek
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-03-11 15:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-11 10:24 [PATCH] Change order of freeing contacts data in send_pull_part Radoslaw Jablonski
2011-03-11 15:46 ` Radoslaw Jablonski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).