tipc: avoid to asynchronously notify subscriptions
Postpone the actions of notifying subscriptions until after node lock
is released, avoiding to asynchronously execute registered handlers
when node is lost.
Signed-off-by: Ying Xue <ying.xue@windriver.com>
Reviewed-by: Erik Hugne <erik.hugne@ericsson.com>
Reviewed-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
diff --git a/net/tipc/node.c b/net/tipc/node.c
index 2b0a084..befbcc9 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -321,10 +321,10 @@
}
/* Notify subscribers */
- tipc_nodesub_notify(n_ptr);
+ n_ptr->flags = TIPC_NODE_LOST;
/* Prevent re-contact with node until cleanup is done */
- n_ptr->flags = TIPC_NODE_DOWN | TIPC_NAMES_GONE;
+ n_ptr->flags |= TIPC_NODE_DOWN | TIPC_NAMES_GONE;
tipc_k_signal((Handler)node_name_purge_complete, n_ptr->addr);
}
@@ -465,3 +465,22 @@
tipc_node_unlock(node);
return -EINVAL;
}
+
+void tipc_node_unlock(struct tipc_node *node)
+{
+ LIST_HEAD(nsub_list);
+
+ if (likely(!node->flags)) {
+ spin_unlock_bh(&node->lock);
+ return;
+ }
+
+ if (node->flags & TIPC_NODE_LOST) {
+ list_replace_init(&node->nsub, &nsub_list);
+ node->flags &= ~TIPC_NODE_LOST;
+ }
+ spin_unlock_bh(&node->lock);
+
+ if (!list_empty(&nsub_list))
+ tipc_nodesub_notify(&nsub_list);
+}