X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fovsdb-idl.c;h=94784bdaabfb236e10351da9adbcac983dffa7a8;hb=c3729ee42dc25a8240cee6c0041b7db3e4070414;hp=e1b53f4eb3730de0aaf3ec3f1153722d20847d17;hpb=dcd1dbc5b3088b1729238be752e75e89cbe1fa27;p=openvswitch diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c index e1b53f4e..94784bda 100644 --- a/lib/ovsdb-idl.c +++ b/lib/ovsdb-idl.c @@ -1108,6 +1108,15 @@ ovsdb_idl_get(const struct ovsdb_idl_row *row, return ovsdb_idl_read(row, column); } + +/* Returns false if 'row' was obtained from the IDL, true if it was initialized + * to all-zero-bits by some other entity. If 'row' was set up some other way + * then the return value is indeterminate. */ +bool +ovsdb_idl_row_is_synthetic(const struct ovsdb_idl_row *row) +{ + return row->table == NULL; +} /* Transactions. */ @@ -1420,6 +1429,8 @@ ovsdb_idl_txn_commit(struct ovsdb_idl_txn *txn) } else { struct ovsdb_idl_txn_insert *insert; + any_updates = true; + json_object_put(op, "uuid-name", json_string_create_nocopy( uuid_name_from_uuid(&row->uuid))); @@ -1447,13 +1458,22 @@ ovsdb_idl_txn_commit(struct ovsdb_idl_txn *txn) ovsdb_datum_to_json(&row->new[idx], &column->type), txn)); + + /* If anything really changed, consider it an update. + * We can't suppress not-really-changed values earlier + * or transactions would become nonatomic (see the big + * comment inside ovsdb_idl_txn_write()). */ + if (!any_updates && row->old && + !ovsdb_datum_equals(&row->old[idx], &row->new[idx], + &column->type)) { + any_updates = true; + } } } } if (!row->old || !shash_is_empty(json_object(row_json))) { json_array_add(operations, op); - any_updates = true; } else { json_destroy(op); } @@ -1642,7 +1662,10 @@ ovsdb_idl_txn_write(const struct ovsdb_idl_row *row_, * * We don't do this for read/write columns because that would break * atomicity of transactions--some other client might have written a - * different value in that column since we read it. */ + * different value in that column since we read it. (But if a whole + * transaction only does writes of existing values, without making any real + * changes, we will drop the whole transaction later in + * ovsdb_idl_txn_commit().) */ if (row->table->modes[column_idx] == OVSDB_IDL_MONITOR && ovsdb_datum_equals(ovsdb_idl_read(row, column), datum, &column->type)) {