From: Mark H. <ma...@os...> - 2004-05-10 18:22:29
|
Jon, Here are updates for the node subscription structures. Are there any that are left to be done? I had considered the publication lists in the sub_seq struct, but since they are copied around when sub sequences come and go, their list_head next/prev pointers become invalid. One way around this would be to change the *sseqs pointer in name_seq to a **sseqs and allocate an array of pointers. Then the pointers could be sorted and the sub_seq structures addresses wouldn't change. Mark. cvs diff -u node.h node_subscr.h name_table.h node_subscr.c name_table.c port.c node.c Index: node.h =================================================================== RCS file: /cvsroot/tipc/source/unstable/net/tipc/node.h,v retrieving revision 1.8 diff -u -r1.8 node.h --- node.h 7 May 2004 22:17:26 -0000 1.8 +++ node.h 10 May 2004 17:34:37 -0000 @@ -97,7 +97,7 @@ int last_router; struct cluster* owner; tipc_net_addr_t addr; - struct node_subscr* subscr; + struct list_head nsub; struct node* next; uint tag; uint last_in_bcast; Index: node_subscr.h =================================================================== RCS file: /cvsroot/tipc/source/unstable/net/tipc/node_subscr.h,v retrieving revision 1.2 diff -u -r1.2 node_subscr.h --- node_subscr.h 3 Feb 2004 23:27:35 -0000 1.2 +++ node_subscr.h 10 May 2004 17:34:37 -0000 @@ -69,8 +69,7 @@ void *usr_handle; net_ev_handler handle_node_down; struct node* node; - struct node_subscr *next; - struct node_subscr *prev; + struct list_head nodesub_list; }; void nodesub_subscribe(struct node_subscr *, Index: node_subscr.c =================================================================== RCS file: /cvsroot/tipc/source/unstable/net/tipc/node_subscr.c,v retrieving revision 1.2 diff -u -r1.2 node_subscr.c --- node_subscr.c 3 Feb 2004 23:27:35 -0000 1.2 +++ node_subscr.c 10 May 2004 17:34:38 -0000 @@ -104,11 +104,7 @@ this->usr_handle = usr_handle; assert(this->node); spin_lock_bh(&this->node->lock); - this->prev = 0; - this->next = this->node->subscr; - if (this->next) - this->next->prev = this; - this->node->subscr = this; + list_add_tail(&this->nodesub_list, &this->node->nsub); spin_unlock_bh(&this->node->lock); } @@ -118,11 +114,6 @@ if (!this->node) return; spin_lock_bh(&this->node->lock); - if (this->next) - this->next->prev = this->prev; - if (this->prev) - this->prev->next = this->next; - else - this->node->subscr = this->next; + list_del_init(&this->nodesub_list); spin_unlock_bh(&this->node->lock); } Index: name_table.c =================================================================== RCS file: /cvsroot/tipc/source/unstable/net/tipc/name_table.c,v retrieving revision 1.17 diff -u -r1.17 name_table.c --- name_table.c 6 May 2004 22:31:06 -0000 1.17 +++ name_table.c 10 May 2004 17:34:38 -0000 @@ -168,6 +168,7 @@ this->key = key; INIT_LIST_HEAD(&this->local_list); INIT_LIST_HEAD(&this->pport_list); + INIT_LIST_HEAD(&this->subscr.nodesub_list); if (node != tipc_own_addr) { nodesub_subscribe(&this->subscr, node, this, (net_ev_handler) publ_handle_node_down); Index: port.c =================================================================== RCS file: /cvsroot/tipc/source/unstable/net/tipc/port.c,v retrieving revision 1.18 diff -u -r1.18 port.c --- port.c 6 May 2004 22:31:06 -0000 1.18 +++ port.c 10 May 2004 17:34:38 -0000 @@ -303,6 +303,7 @@ this->sent = 1; this->publ.usr_handle = usr_handle; INIT_LIST_HEAD(&this->wait_list); + INIT_LIST_HEAD(&this->subscription.nodesub_list); this->congested_link = 0; this->max_pkt = 1404; /* Ethernet, adjust at connect */ this->dispatcher = dispatcher; Index: node.c =================================================================== RCS file: /cvsroot/tipc/source/unstable/net/tipc/node.c,v retrieving revision 1.17 diff -u -r1.17 node.c --- node.c 7 May 2004 22:17:26 -0000 1.17 +++ node.c 10 May 2004 17:34:38 -0000 @@ -129,6 +129,7 @@ this->lock = SPIN_LOCK_UNLOCKED; this->acked_bcast = 0; this->last_in_bcast = 0; + INIT_LIST_HEAD(&this->nsub); if (!c) @@ -436,7 +437,7 @@ node_lost_contact(struct node *this) { uint i; - struct node_subscr *crs = this->subscr; + struct node_subscr *ns, *tns; struct cluster *c; if (is_slave(tipc_own_addr)) { @@ -476,14 +477,11 @@ link_reset_fragments(l); } - this->subscr = 0; /* One-shot subscribers */ - /* Notify subscribers: */ - while (crs){ - struct node_subscr *next = crs->next; - crs->node = 0; - crs->handle_node_down(crs->usr_handle); - crs = next; + list_for_each_entry_safe(ns, tns, &this->nsub, nodesub_list) { + ns->node = 0; + list_del_init(&ns->nodesub_list); + ns->handle_node_down(ns->usr_handle); } } -- Mark Haverkamp <ma...@os...> |