diff options
author | Inga Stotland <inga.stotland@intel.com> | 2020-06-10 10:11:21 -0700 |
---|---|---|
committer | Brian Gix <brian.gix@intel.com> | 2020-06-10 10:27:17 -0700 |
commit | 7bcb1086ab310f414a9bfe78b17f5a4429d1375c (patch) | |
tree | fba090fb097d04b4a2467507611de768d1875fc8 /mesh/mesh.c | |
parent | 4de95f9fbedce881f68db548cb666a01a94bdf11 (diff) | |
download | bluez-7bcb1086ab310f414a9bfe78b17f5a4429d1375c.tar.gz |
mesh: Add "node is busy" check for Leave() & Attach()
This introduces the following behavior change for those methods
on Network interface that specify node token as an input parameter
Leave() method:
If Leave method is called for a node that is being processed as a result
of a Create, Import, Join or Attach method calls in progress, node removal
is not allowed and org.bluez.mesh.Error.Busy error is returned.
Attach() method:
If Attach method is called for a node that is being processed as a result
of a Create, Import or Join method calls in progress, node attachment
is not allowed and org.bluez.mesh.Error.Busy error is returned.
Diffstat (limited to 'mesh/mesh.c')
-rw-r--r-- | mesh/mesh.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/mesh/mesh.c b/mesh/mesh.c index a5935c216..c8767ee7a 100644 --- a/mesh/mesh.c +++ b/mesh/mesh.c @@ -655,13 +655,21 @@ static struct l_dbus_message *leave_call(struct l_dbus *dbus, void *user_data) { uint64_t token; + struct mesh_node *node; l_debug("Leave"); if (!l_dbus_message_get_arguments(msg, "t", &token)) return dbus_error(msg, MESH_ERROR_INVALID_ARGS, NULL); - node_remove(node_find_by_token(token)); + node = node_find_by_token(token); + if (!node) + return dbus_error(msg, MESH_ERROR_NOT_FOUND, NULL); + + if (node_is_busy(node)) + return dbus_error(msg, MESH_ERROR_BUSY, NULL); + + node_remove(node); return l_dbus_message_new_method_return(msg); } |