Thank you for your answers very much.

#############
Actually I have add events I care about between poll_timer_wait and
poll_block.

What I want is:
if the event I care about happens, then wake up immediately;
if the event I care about does not happens, then wake up after 1000ms;

I test my codes, it seems works ...

#############
I don't know is there any better way to do this, which is commit in 1s.

I searched in OVS, I found that there is only one place does not use
commit_block, it's vswitchd. Vswitchd remember the txn, if commit is
TXN_INCOMPLETE, vswitchd will commit the txn next time.

But I want is commit txn less in 1s or a specific time, and I don't care
job fails, so I have to write codes like that ...


2015-01-22 15:01 GMT+08:00 Ben Pfaff <[email protected]>:

> On Thu, Jan 22, 2015 at 01:37:50PM +0800, yewgang wrote:
> > These codes is only an example, I decide to write codes in my project by
> > hand like below:
> >
> > for (i = 0; i < LOOP_COUNT_DEFINE_BY_MYSELF; i++) {
> >     status = ovsdb_idl_txn_commit(txn)
> >     if (status != TXN_INCOMPLETE)
> >          break;
> >
> >     poll_timer_wait(1000);
> >     ....
> >     poll_block();
> > }
> >
> > I hope the commit-loop will end in LOOP_COUNT_DEFINE_BY_MYSELF loops.
>
> OK.
>
> If you need the loop to break when some event occurs, then usually you
> should arrange for it to check for and to wake up when that specific
> event occurs.  The code as you write it above won't actually help with
> that because it doesn't check for your event in the loop, even every
> 1000 ms.  I also don't think that hard-coding a maximum iteration count
> like LOOP_COUNT_DEFINE_BY_MYSELF is a good idea, because there's no way
> to predict how many iterations it will take to process the transaction.
>
> I'm not sure that you understand event-driven programming.
>
> > But what I get is TXN_ERROR
> > That really confused me ...
>
> You're probably doing something wrong, but I have no way to guess what.
>
_______________________________________________
discuss mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/discuss

Reply via email to