* [PATCH BlueZ 0/2] mesh: Clean up D-Bus message references
@ 2019-05-22 5:33 Inga Stotland
2019-05-22 5:33 ` [PATCH BlueZ 1/2] mesh: Unreference pending D-Bus messages Inga Stotland
2019-05-22 5:33 ` [PATCH BlueZ 2/2] mesh: Remove unnecessary message ref/unref in agent.c Inga Stotland
0 siblings, 2 replies; 3+ messages in thread
From: Inga Stotland @ 2019-05-22 5:33 UTC (permalink / raw)
To: linux-bluetooth; +Cc: brian.gix, johan.hedberg, luiz.dentz, Inga Stotland
This set of patches cleans up the usage of l_dbus_message_ref() and
l_dbus_message_unref() in the mesh daemon
Inga Stotland (2):
mesh: Unreference pending D-Bus messages
mesh: Remove unnecessary message ref/unref in agent.c
mesh/agent.c | 16 ----------------
mesh/mesh.c | 8 +++++---
2 files changed, 5 insertions(+), 19 deletions(-)
--
2.21.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH BlueZ 1/2] mesh: Unreference pending D-Bus messages
2019-05-22 5:33 [PATCH BlueZ 0/2] mesh: Clean up D-Bus message references Inga Stotland
@ 2019-05-22 5:33 ` Inga Stotland
2019-05-22 5:33 ` [PATCH BlueZ 2/2] mesh: Remove unnecessary message ref/unref in agent.c Inga Stotland
1 sibling, 0 replies; 3+ messages in thread
From: Inga Stotland @ 2019-05-22 5:33 UTC (permalink / raw)
To: linux-bluetooth; +Cc: brian.gix, johan.hedberg, luiz.dentz, Inga Stotland
This change results in proper cleanup of D-Bus messages for pending
replies: if l_dbus_message_ref() was called for a message, then
l_dbus_message_unref() must be called for the same message to completely
free the message resources.
---
mesh/mesh.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/mesh/mesh.c b/mesh/mesh.c
index 231a6bca4..bed8484f2 100644
--- a/mesh/mesh.c
+++ b/mesh/mesh.c
@@ -354,6 +354,9 @@ static void free_pending_join_call(bool failed)
mesh_agent_remove(join_pending->agent);
+ if (join_pending->msg)
+ l_dbus_message_unref(join_pending->msg);
+
if (failed)
node_remove(join_pending->node);
@@ -422,9 +425,6 @@ static void prov_disc_cb(struct l_dbus *bus, void *user_data)
if (!join_pending)
return;
- if (join_pending->msg)
- l_dbus_message_unref(join_pending->msg);
-
acceptor_cancel(&mesh);
join_pending->disc_watch = 0;
@@ -650,6 +650,7 @@ static void attach_ready_cb(void *user_data, int status, struct mesh_node *node)
done:
l_dbus_send(dbus_get_bus(), reply);
+ l_dbus_message_unref(pending_msg);
l_queue_remove(pending_queue, pending_msg);
}
@@ -727,6 +728,7 @@ static void create_network_ready_cb(void *user_data, int status,
done:
l_dbus_send(dbus_get_bus(), reply);
+ l_dbus_message_unref(pending_msg);
l_queue_remove(pending_queue, pending_msg);
}
--
2.21.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH BlueZ 2/2] mesh: Remove unnecessary message ref/unref in agent.c
2019-05-22 5:33 [PATCH BlueZ 0/2] mesh: Clean up D-Bus message references Inga Stotland
2019-05-22 5:33 ` [PATCH BlueZ 1/2] mesh: Unreference pending D-Bus messages Inga Stotland
@ 2019-05-22 5:33 ` Inga Stotland
1 sibling, 0 replies; 3+ messages in thread
From: Inga Stotland @ 2019-05-22 5:33 UTC (permalink / raw)
To: linux-bluetooth; +Cc: brian.gix, johan.hedberg, luiz.dentz, Inga Stotland
This removes calls to reference/unrefernce D-Bus messages for
the methods that are called on org.bluez.mesh.ProvisionAgent1
interface since the referenced messages are not used.
---
mesh/agent.c | 16 ----------------
1 file changed, 16 deletions(-)
diff --git a/mesh/agent.c b/mesh/agent.c
index 4f99bad7b..1cd09eee8 100644
--- a/mesh/agent.c
+++ b/mesh/agent.c
@@ -199,7 +199,6 @@ static void agent_free(void *agent_data)
break;
}
- l_dbus_message_unref(req->msg);
l_free(req);
}
@@ -310,8 +309,6 @@ static void simple_reply(struct l_dbus_message *reply, void *user_data)
err = get_reply_error(reply);
- l_dbus_message_unref(req->msg);
-
if (req->cb) {
cb = req->cb;
cb(req->user_data, err);
@@ -345,8 +342,6 @@ static void numeric_reply(struct l_dbus_message *reply, void *user_data)
}
}
- l_dbus_message_unref(req->msg);
-
if (req->cb) {
cb = req->cb;
cb(req->user_data, err, count);
@@ -402,8 +397,6 @@ static void key_reply(struct l_dbus_message *reply, void *user_data)
}
done:
- l_dbus_message_unref(req->msg);
-
if (req->cb) {
cb = req->cb;
cb(req->user_data, err, buf, n);
@@ -444,8 +437,6 @@ static int output_request(struct mesh_agent *agent, const char *action,
l_dbus_send_with_reply(dbus_get_bus(), msg, simple_reply, agent,
NULL);
- agent->req->msg = l_dbus_message_ref(msg);
-
return MESH_ERROR_NONE;
}
@@ -486,8 +477,6 @@ static int prompt_input(struct mesh_agent *agent, const char *action,
l_dbus_send_with_reply(dbus_get_bus(), msg, reply_cb, agent, NULL);
- agent->req->msg = l_dbus_message_ref(msg);
-
return MESH_ERROR_NONE;
}
@@ -519,8 +508,6 @@ static int request_key(struct mesh_agent *agent,
l_dbus_send_with_reply(dbus_get_bus(), msg, key_reply, agent, NULL);
- agent->req->msg = l_dbus_message_ref(msg);
-
return MESH_ERROR_NONE;
}
@@ -554,10 +541,7 @@ int mesh_agent_display_string(struct mesh_agent *agent, const char *str,
l_dbus_send_with_reply(dbus_get_bus(), msg, simple_reply, agent,
NULL);
- agent->req->msg = l_dbus_message_ref(msg);
-
return MESH_ERROR_NONE;
-
}
int mesh_agent_display_number(struct mesh_agent *agent, bool initiator,
--
2.21.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-05-22 5:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-22 5:33 [PATCH BlueZ 0/2] mesh: Clean up D-Bus message references Inga Stotland
2019-05-22 5:33 ` [PATCH BlueZ 1/2] mesh: Unreference pending D-Bus messages Inga Stotland
2019-05-22 5:33 ` [PATCH BlueZ 2/2] mesh: Remove unnecessary message ref/unref in agent.c Inga Stotland
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.