Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH] Add checking for agent reply state in adapter
@ 2010-09-28  9:17 Radoslaw Jablonski
  2010-09-28 11:18 ` Johan Hedberg
  0 siblings, 1 reply; 2+ messages in thread
From: Radoslaw Jablonski @ 2010-09-28  9:17 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Radoslaw Jablonski

Added checking for agent reply state before cancelling agent in
session_free(..). This check is needed to ensure that memory for
agent request will be freed only once (In that case, free on this
request is called later in the end of agent_reply func)
---
 src/adapter.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index 0e9be5f..c122f82 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -82,6 +82,7 @@ struct session_req {
 	guint			id;		/* Listener id */
 	uint8_t			mode;		/* Requested mode */
 	int			refcount;	/* Session refcount */
+	gboolean		is_reply;	/* Agent reply is present */
 };
 
 struct service_auth {
@@ -757,7 +758,9 @@ static void session_free(struct session_req *req)
 
 	if (req->msg) {
 		dbus_message_unref(req->msg);
-		if (req->mode && req->adapter->agent)
+		/* if initial reply is present, we shouldn't cancel agent,
+		 * because it will be done later in agent_reply function */
+		if (!req->is_reply && req->mode && req->adapter->agent)
 			agent_cancel(req->adapter->agent);
 	}
 
@@ -794,6 +797,7 @@ static void confirm_mode_cb(struct agent *agent, DBusError *derr, void *data)
 	int err;
 	DBusMessage *reply;
 
+	req->is_reply = TRUE;
 	if (derr && dbus_error_is_set(derr)) {
 		reply = dbus_message_new_error(req->msg, derr->name,
 						derr->message);
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Add checking for agent reply state in adapter
  2010-09-28  9:17 [PATCH] Add checking for agent reply state in adapter Radoslaw Jablonski
@ 2010-09-28 11:18 ` Johan Hedberg
  0 siblings, 0 replies; 2+ messages in thread
From: Johan Hedberg @ 2010-09-28 11:18 UTC (permalink / raw)
  To: Radoslaw Jablonski; +Cc: linux-bluetooth

Hi Radek,

On Tue, Sep 28, 2010, Radoslaw Jablonski wrote:
> Added checking for agent reply state before cancelling agent in
> session_free(..). This check is needed to ensure that memory for
> agent request will be freed only once (In that case, free on this
> request is called later in the end of agent_reply func)
> ---
>  src/adapter.c |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)

Thanks. The patch has been pushed upstream with s/is_reply/got_reply/
which is more intuitive imho.

Johan

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-09-28 11:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-28  9:17 [PATCH] Add checking for agent reply state in adapter Radoslaw Jablonski
2010-09-28 11:18 ` Johan Hedberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox