[ovs-dev] [PATCH 2/8] ovsdb: Centralize and make consistent setting txn_row members of rows.
Ben Pfaff
blp at nicira.com
Mon Mar 15 22:42:50 UTC 2010
When a transaction modified a row, the "old" row's txn_row member was
not being set to the txn_row. This commit changes that and factors out
the code to set the txn_row member of the rows within a txn_row.
This is not a bug fix, because nothing previously cared about the txn_row
member of the old version of a row, but it does matter for an upcoming
commit.
---
ovsdb/transaction.c | 18 +++++++++++++-----
1 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/ovsdb/transaction.c b/ovsdb/transaction.c
index 137ae06..154f811 100644
--- a/ovsdb/transaction.c
+++ b/ovsdb/transaction.c
@@ -343,15 +343,23 @@ ovsdb_txn_create_txn_table(struct ovsdb_txn *txn, struct ovsdb_table *table)
static struct ovsdb_txn_row *
ovsdb_txn_row_create(struct ovsdb_txn *txn, struct ovsdb_table *table,
- const struct ovsdb_row *old, struct ovsdb_row *new)
+ const struct ovsdb_row *old_, struct ovsdb_row *new)
{
+ struct ovsdb_row *old = (struct ovsdb_row *) old_;
struct ovsdb_txn_table *txn_table;
struct ovsdb_txn_row *txn_row;
txn_row = xmalloc(sizeof *txn_row);
- txn_row->old = (struct ovsdb_row *) old;
+ txn_row->old = old;
txn_row->new = new;
+ if (old) {
+ old->txn_row = txn_row;
+ }
+ if (new) {
+ new->txn_row = txn_row;
+ }
+
txn_table = ovsdb_txn_create_txn_table(txn, table);
hmap_insert(&txn_table->txn_rows, &txn_row->hmap_node,
ovsdb_row_hash(old ? old : new));
@@ -374,7 +382,7 @@ ovsdb_txn_row_modify(struct ovsdb_txn *txn, const struct ovsdb_row *ro_row_)
rw_row = ovsdb_row_clone(ro_row);
rw_row->n_refs = ro_row->n_refs;
uuid_generate(ovsdb_row_get_version_rw(rw_row));
- rw_row->txn_row = ovsdb_txn_row_create(txn, table, ro_row, rw_row);
+ ovsdb_txn_row_create(txn, table, ro_row, rw_row);
hmap_replace(&table->rows, &ro_row->hmap_node, &rw_row->hmap_node);
return rw_row;
@@ -389,7 +397,7 @@ ovsdb_txn_row_insert(struct ovsdb_txn *txn, struct ovsdb_row *row)
uuid_generate(ovsdb_row_get_version_rw(row));
- row->txn_row = ovsdb_txn_row_create(txn, table, NULL, row);
+ ovsdb_txn_row_create(txn, table, NULL, row);
hmap_insert(&table->rows, &row->hmap_node, hash);
}
@@ -405,7 +413,7 @@ ovsdb_txn_row_delete(struct ovsdb_txn *txn, const struct ovsdb_row *row_)
hmap_remove(&table->rows, &row->hmap_node);
if (!txn_row) {
- row->txn_row = ovsdb_txn_row_create(txn, table, row, NULL);
+ ovsdb_txn_row_create(txn, table, row, NULL);
} else {
assert(txn_row->new == row);
if (txn_row->old) {
--
1.6.6.1
More information about the dev
mailing list