summaryrefslogtreecommitdiff
path: root/net/tipc/node.c
diff options
context:
space:
mode:
authorYing Xue <ying.xue@windriver.com>2014-05-05 08:56:12 +0800
committerDavid S. Miller <davem@davemloft.net>2014-05-05 17:26:44 -0400
commit9db9fdd1983eb960182d72f95d77b91b3a5173d0 (patch)
tree0c4d21174478529972f3b630f7b1daa6f018f134 /net/tipc/node.c
parent10f465c4966fbc8f50a59480d37a3451f6f3d564 (diff)
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>
Diffstat (limited to 'net/tipc/node.c')
-rw-r--r--net/tipc/node.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/net/tipc/node.c b/net/tipc/node.c
index 2b0a0849d4cc..befbcc9eade6 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -321,10 +321,10 @@ static void node_lost_contact(struct tipc_node *n_ptr)
}
/* 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 @@ int tipc_node_get_linkname(u32 bearer_id, u32 addr, char *linkname, size_t len)
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);
+}