aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/net.c
diff options
context:
space:
mode:
authorYing Xue <ying.xue@windriver.com>2014-03-27 00:54:36 -0400
committerDavid S. Miller <davem@davemloft.net>2014-03-27 13:08:37 -0400
commit46651c59c483f14fd35cf7df2104feac0e54e258 (patch)
tree06945336cf5bab75a27df13f7a6408d5d1e88672 /net/tipc/net.c
parent987b58be376b8d087a9bb677f50592efc6ccb7c5 (diff)
tipc: rename node create lock to protect node list and hlist
When a node is created, tipc_net_lock read lock is first held and then node_create_lock is grabbed in order to prevent the same node from being created and inserted into both node list and hlist twice. But when we query node from the two node lists, we only hold tipc_net_lock read lock without grabbing node_create_lock. Obviously this locking policy is unable to guarantee that the two node lists are always synchronized especially when the operation of changing and accessing them occurs in different contexts like currently doing. Therefore, rename node_create_lock to node_list_lock to protect the two node lists, that is, whenever node is inserted into them or node is queried from them, the node_list_lock should be always held. As a result, tipc_net_lock read lock becomes redundant and then can be removed from the node query functions. 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/net.c')
-rw-r--r--net/tipc/net.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/net/tipc/net.c b/net/tipc/net.c
index bb171c3f90d3..0374a817631e 100644
--- a/net/tipc/net.c
+++ b/net/tipc/net.c
@@ -189,15 +189,14 @@ void tipc_net_start(u32 addr)
189 189
190void tipc_net_stop(void) 190void tipc_net_stop(void)
191{ 191{
192 struct tipc_node *node, *t_node;
193
194 if (!tipc_own_addr) 192 if (!tipc_own_addr)
195 return; 193 return;
194
196 write_lock_bh(&tipc_net_lock); 195 write_lock_bh(&tipc_net_lock);
197 tipc_bearer_stop(); 196 tipc_bearer_stop();
198 tipc_bclink_stop(); 197 tipc_bclink_stop();
199 list_for_each_entry_safe(node, t_node, &tipc_node_list, list) 198 tipc_node_stop();
200 tipc_node_delete(node);
201 write_unlock_bh(&tipc_net_lock); 199 write_unlock_bh(&tipc_net_lock);
200
202 pr_info("Left network mode\n"); 201 pr_info("Left network mode\n");
203} 202}