Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 102611
b: refs/heads/master
c: 2ecb092
h: refs/heads/master
i:
  102609: 1da7e7d
  102607: 7906ff8
v: v3
  • Loading branch information
Allan Stephens authored and David S. Miller committed May 21, 2008
1 parent c595a8e commit d89f808
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 59f0c4523fdea865fab7d69d878269992a9d08dd
refs/heads/master: 2ecb0924d7791372a70ef8f1174e37b329b955c3
26 changes: 26 additions & 0 deletions trunk/net/tipc/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,40 @@ static void node_established_contact(struct node *n_ptr);

struct node *tipc_nodes = NULL; /* sorted list of nodes within cluster */

static DEFINE_SPINLOCK(node_create_lock);

u32 tipc_own_tag = 0;

/**
* tipc_node_create - create neighboring node
*
* Currently, this routine is called by neighbor discovery code, which holds
* net_lock for reading only. We must take node_create_lock to ensure a node
* isn't created twice if two different bearers discover the node at the same
* time. (It would be preferable to switch to holding net_lock in write mode,
* but this is a non-trivial change.)
*/

struct node *tipc_node_create(u32 addr)
{
struct cluster *c_ptr;
struct node *n_ptr;
struct node **curr_node;

spin_lock_bh(&node_create_lock);

for (n_ptr = tipc_nodes; n_ptr; n_ptr = n_ptr->next) {
if (addr < n_ptr->addr)
break;
if (addr == n_ptr->addr) {
spin_unlock_bh(&node_create_lock);
return n_ptr;
}
}

n_ptr = kzalloc(sizeof(*n_ptr),GFP_ATOMIC);
if (!n_ptr) {
spin_unlock_bh(&node_create_lock);
warn("Node creation failed, no memory\n");
return NULL;
}
Expand All @@ -71,6 +95,7 @@ struct node *tipc_node_create(u32 addr)
c_ptr = tipc_cltr_create(addr);
}
if (!c_ptr) {
spin_unlock_bh(&node_create_lock);
kfree(n_ptr);
return NULL;
}
Expand All @@ -91,6 +116,7 @@ struct node *tipc_node_create(u32 addr)
}
}
(*curr_node) = n_ptr;
spin_unlock_bh(&node_create_lock);
return n_ptr;
}

Expand Down

0 comments on commit d89f808

Please sign in to comment.