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

yewgang batmanustc at gmail.com
Thu Jan 22 05:37:50 UTC 2015


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.
But what I get is TXN_ERROR
That really confused me ...

2015-01-22 12:49 GMT+08:00 Ben Pfaff <blp at nicira.com>:

> It's not what I recommended.  If you're not going to take my advice
> anyway then I don't see much point in giving more of it.
>
> On Thu, Jan 22, 2015 at 11:01:54AM +0800, yewgang wrote:
> > Thank you. I don't know if these codes will give me faster response ?
> Could
> > I change codes like this ?
> >
> > enum ovsdb_idl_txn_status
> > ovsdb_idl_txn_commit_block(struct ovsdb_idl_txn *txn)
> > {
> >     enum ovsdb_idl_txn_status status;
> >
> >     fatal_signal_run();
> >     while ((status = ovsdb_idl_txn_commit(txn)) == TXN_INCOMPLETE) {
> >         *poll_timer_wait(1000);*
> >         ovsdb_idl_run(txn->idl);
> >         ovsdb_idl_wait(txn->idl);
> >         ovsdb_idl_txn_wait(txn);
> >         poll_block();
> >     }
> >     return status;
> > }
> >
> >
> > Also there is another problem, I don't know if these codes will work.
> >
> > As there is a while loop, if ovsdb-server continue block and no answer
> > return, will the loop be dead-loop ?
> >
> >
> > 2015-01-20 2:19 GMT+08:00 Ben Pfaff <blp at nicira.com>:
> >
> > > On Mon, Jan 19, 2015 at 03:49:21PM +0800, yewgang wrote:
> > > > Now for some reason I have to write codes like this (My program
> perform
> > > > ovsdb-client):
> > > >
> > > > LOOP {
> > > >     ........
> > > >     important task every 2 second;
> > > >     ovsdb_idl_txn_commit_block(txn);
> > > >     ........
> > > > }
> > > >
> > > > If ovsdb-server is OK, ovsdb_idl_txn_commit_block will not block;
> but if
> > > > ovsdb-server is blocked or network is blocked, Is there any possible
> for
> > > my
> > > > program blocking at *poll_block()* (in ovsdb_idl_txn_commit_block
> > > function)
> > > > for long time ?
> > >
> > > If it takes a long time for a network response, then, yes, poll_block()
> > > could block for 2 seconds or more.
> > >
> > > If you need faster response than that then you probably shouldn't use
> > > ovsdb_idl_txn_commit_block().  Use ovsdb_idl_txn_commit() and
> > > poll_block() by hand, plus poll_timer_wait() or poll_timer_wait_until()
> > > to ensure that poll_block() wakes up by your deadline.
> > >
>
> > _______________________________________________
> > discuss mailing list
> > discuss at openvswitch.org
> > http://openvswitch.org/mailman/listinfo/discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://openvswitch.org/pipermail/ovs-discuss/attachments/20150122/4ef4cde0/attachment-0002.html>


More information about the discuss mailing list