X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fovsdb-idl.c;h=19ae16fe54d0282b6bf3ae249dea6cbbce60db8e;hb=40f280c781639c24176e054abc20bb7270da9e7a;hp=56b432868c71077f5b9401d3c006e0263f874100;hpb=9b446bfaa25c3cf44ace4821bd06c675d432df56;p=openvswitch diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c index 56b43286..19ae16fe 100644 --- a/lib/ovsdb-idl.c +++ b/lib/ovsdb-idl.c @@ -91,6 +91,7 @@ struct ovsdb_idl_txn { char *error; bool dry_run; struct ds comment; + unsigned int commit_seqno; /* Increments. */ char *inc_table; @@ -1111,8 +1112,13 @@ const struct ovsdb_datum * ovsdb_idl_read(const struct ovsdb_idl_row *row, const struct ovsdb_idl_column *column) { - const struct ovsdb_idl_table_class *class = row->table->class; - size_t column_idx = column - class->columns; + const struct ovsdb_idl_table_class *class; + size_t column_idx; + + assert(!ovsdb_idl_row_is_synthetic(row)); + + class = row->table->class; + column_idx = column - class->columns; assert(row->new != NULL); assert(column_idx < class->n_columns); @@ -1173,8 +1179,10 @@ ovsdb_idl_txn_status_to_string(enum ovsdb_idl_txn_status status) return "aborted"; case TXN_SUCCESS: return "success"; - case TXN_TRY_AGAIN: - return "try again"; + case TXN_AGAIN_WAIT: + return "wait then try again"; + case TXN_AGAIN_NOW: + return "try again now"; case TXN_NOT_LOCKED: return "not locked"; case TXN_ERROR: @@ -1197,6 +1205,7 @@ ovsdb_idl_txn_create(struct ovsdb_idl *idl) txn->error = NULL; txn->dry_run = false; ds_init(&txn->comment); + txn->commit_seqno = txn->idl->change_seqno; txn->inc_table = NULL; txn->inc_column = NULL; @@ -1587,7 +1596,7 @@ ovsdb_idl_txn_commit(struct ovsdb_idl_txn *txn) json_hash(txn->request_id, 0)); txn->status = TXN_INCOMPLETE; } else { - txn->status = TXN_TRY_AGAIN; + txn->status = TXN_AGAIN_WAIT; } ovsdb_idl_txn_disassemble(txn); @@ -1762,7 +1771,9 @@ ovsdb_idl_txn_write(const struct ovsdb_idl_row *row_, * prerequisite to completing the transaction. That is, if 'column' in 'row_' * changed (or if 'row_' was deleted) between the time that the IDL originally * read its contents and the time that the transaction commits, then the - * transaction aborts and ovsdb_idl_txn_commit() returns TXN_TRY_AGAIN. + * transaction aborts and ovsdb_idl_txn_commit() returns TXN_AGAIN_WAIT or + * TXN_AGAIN_NOW (depending on whether the database change has already been + * received). * * The intention is that, to ensure that no transaction commits based on dirty * reads, an application should call ovsdb_idl_txn_verify() on each data item @@ -1890,7 +1901,7 @@ ovsdb_idl_txn_abort_all(struct ovsdb_idl *idl) struct ovsdb_idl_txn *txn; HMAP_FOR_EACH (txn, hmap_node, &idl->outstanding_txns) { - ovsdb_idl_txn_complete(txn, TXN_TRY_AGAIN); + ovsdb_idl_txn_complete(txn, TXN_AGAIN_WAIT); } } @@ -2091,7 +2102,9 @@ ovsdb_idl_txn_process_reply(struct ovsdb_idl *idl, status = (hard_errors ? TXN_ERROR : lock_errors ? TXN_NOT_LOCKED - : soft_errors ? TXN_TRY_AGAIN + : soft_errors ? (txn->commit_seqno == idl->change_seqno + ? TXN_AGAIN_WAIT + : TXN_AGAIN_NOW) : TXN_SUCCESS); }