[sheepdog] [PATCH v4 1/3] sheep: rework update node logic

MORITA Kazutaka morita.kazutaka at gmail.com
Wed Jul 10 15:13:18 CEST 2013


At Wed, 10 Jul 2013 17:58:45 +0800,
Liu Yuan wrote:
> 
> On Wed, Jul 10, 2013 at 06:07:32PM +0900, MORITA Kazutaka wrote:
> > Sorry, one more comment I've noticed this time.
> > 
> > > @@ -343,6 +346,17 @@ static bool __corosync_dispatch_one(struct corosync_event *cevent)
> > >  		sd_notify_handler(&cevent->sender.ent, cevent->msg,
> > >  						 cevent->msg_len);
> > >  		break;
> > > +	case COROSYNC_EVENT_TYPE_UPDATE_NODE:
> > > +		node = &cevent->sender.ent;
> > > +
> > > +		if (node_eq(node, &this_node.ent))
> > > +			this_node.ent = *node;
> > 
> > Using cpg_node_equal looks cleaner.
> 
> We have to init cpg_node to use cpg_node_equal, it is tedious.

cpg_node_equal() checks whether the cpg_nodes are the same sheep
daemon.  corosync_update_node() set the enough information for the
comparison to cevent->sender, so

  cpg_node_equal(&cevent->sender, &this_node)

should (must) work correctly.  We don't have to initialize any other
variables.

> 
> > 
> > > diff --git a/sheep/cluster/local.c b/sheep/cluster/local.c
> > > index e6fa149..80228b3 100644
> > > --- a/sheep/cluster/local.c
> > > +++ b/sheep/cluster/local.c
> > > @@ -478,6 +478,10 @@ static bool local_process_event(void)
> > >  		sd_notify_handler(&ev->sender.node, ev->buf, ev->buf_len);
> > >  		break;
> > >  	case EVENT_UPDATE_NODE:
> > > +		if (node_eq(&ev->sender.node, &this_node.node))
> > > +			this_node.node = ev->sender.node;
> > 
> > Using lnode_eq looks cleaner.
> 
> ditto.

lnode_eq(&ev->sender, &this_node) should work.

Actually, we already call xlfind in add_event(EVENT_UPDATE_NODE) and
lnode_cmp() is used against the sender lnode.

Thanks,

Kazutaka



More information about the sheepdog mailing list