[ovs-discuss] Fwd: Is there any possible for program blocking here for long time ?

Ben Pfaff blp at nicira.com
Thu Jan 22 07:01:22 UTC 2015


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.



More information about the discuss mailing list