lib/ovsdb-idl.c
/* Attempts to commit the current transaction, if one is open.
 *
 * If a transaction was open, in this or a previous iteration of the main loop,
 * and had not before finished committing (successfully or unsuccessfully), the
 * return value is one of:
 *
 *  1: The transaction committed successfully (or it did not change anything in
 *     the database).
 *  0: The transaction failed.
 * -1: The commit is still in progress.
 *
 * Thus, the return value is -1 if the transaction is in progress and otherwise
 * true for success, false for failure.
 *
 * (In the corner case where the IDL sends a transaction to the database and
 * the database commits it, and the connection between the IDL and the database
 * drops before the IDL receives the message confirming the commit, this
 * function can return 0 even though the transaction succeeded.)
 */
Attempts to commit the current transaction, if one is open.
If a transaction was open, in this or a previous iteration of the main loop,
and had not before finished committing (successfully or unsuccessfully), the
return value is one of.

The transaction committed successfully (or it did not change anything in
the database).
0: The transaction failed.
-1: The commit is still in progress.

Thus, the return value is -1 if the transaction is in progress and otherwise
true for success, false for failure.

(In the corner case where the IDL sends a transaction to the database and
the database commits it, and the connection between the IDL and the database
drops before the IDL receives the message confirming the commit, this
function can return 0 even though the transaction succeeded.)
Attempts to commit the current transaction if one is open . If a transaction was open in this or a previous iteration of the main loop and had not before finished committing ( successfully or unsuccessfully ) the return value is one of . The transaction committed successfully ( or it did not change anything in the database ) . 0 : The transaction failed . - 1 : The commit is still in progress . Thus the return value is - 1 if the transaction is in progress and otherwise true for success false for failure . ( In the corner case where the IDL sends a transaction to the database and the database commits it and the connection between the IDL and the database drops before the IDL receives the message confirming the commit this function can return 0 even though the transaction succeeded . )
static int
ovsdb_idl_try_commit_loop_txn(struct ovsdb_idl_loop *loop,
                              bool *may_need_wakeup)
{
    if (!loop->committing_txn) {
        return 1;
    }
    int retval;
    struct ovsdb_idl_txn *txn = loop->committing_txn;
    enum ovsdb_idl_txn_status status = ovsdb_idl_txn_commit(txn);
    if (status != TXN_INCOMPLETE) {
        switch (status) {
        case TXN_TRY_AGAIN:
            loop->skip_seqno = loop->precommit_seqno;
            if (ovsdb_idl_get_seqno(loop->idl) != loop->skip_seqno
                && may_need_wakeup) {
                *may_need_wakeup = true;
            }
            retval = 0;
            break;
        case TXN_SUCCESS:
            retval = 1;
            loop->cur_cfg = loop->next_cfg;
            if (may_need_wakeup) {
                *may_need_wakeup =  true;
            }
            break;
        case TXN_UNCHANGED:
            retval = 1;
            loop->cur_cfg = loop->next_cfg;
            break;
        case TXN_ABORTED:
        case TXN_NOT_LOCKED:
        case TXN_ERROR:
            retval = 0;
            break;
        case TXN_UNCOMMITTED:
        case TXN_INCOMPLETE:
        default:
            OVS_NOT_REACHED();
        }
        ovsdb_idl_txn_destroy(txn);
        loop->committing_txn = NULL;
    } else {
        retval = -1;
    }
    return retval;
}
static int ovsdb_idl_try_commit_loop_txn ( struct ovsdb_idl_loop * loop , bool * may_need_wakeup ) { if ( ! loop -> committing_txn ) { return 1 ; } int retval ; struct ovsdb_idl_txn * txn = loop -> committing_txn ; enum ovsdb_idl_txn_status status = ovsdb_idl_txn_commit ( txn ) ; if ( status != TXN_INCOMPLETE ) { switch ( status ) { case TXN_TRY_AGAIN : loop -> skip_seqno = loop -> precommit_seqno ; if ( ovsdb_idl_get_seqno ( loop -> idl ) != loop -> skip_seqno && may_need_wakeup ) { * may_need_wakeup = true ; } retval = 0 ; break ; case TXN_SUCCESS : retval = 1 ; loop -> cur_cfg = loop -> next_cfg ; if ( may_need_wakeup ) { * may_need_wakeup = true ; } break ; case TXN_UNCHANGED : retval = 1 ; loop -> cur_cfg = loop -> next_cfg ; break ; case TXN_ABORTED : case TXN_NOT_LOCKED : case TXN_ERROR : retval = 0 ; break ; case TXN_UNCOMMITTED : case TXN_INCOMPLETE : default : OVS_NOT_REACHED ( ) ; } ovsdb_idl_txn_destroy ( txn ) ; loop -> committing_txn = NULL ; } else { retval = -1 ; } return retval ; }
Attempts to commit the current transaction, if one is open.
Attempts to commit the current transaction if one is open .
/* Not a meaningful return value: no transaction was in progress. */ /* We want to re-evaluate the database when it's changed from
             * the contents that it had when we started the commit.  (That
             * might have already happened.) */ /* Possibly some work on the database was deferred because no
             * further transaction could proceed.  Wake up again. */