Catalli's threaded switch
[sliver-openvswitch.git] / ovsdb / row.c
index 52c5ddb..5043cbc 100644 (file)
@@ -35,6 +35,8 @@ allocate_row(const struct ovsdb_table *table)
     struct ovsdb_row *row = xmalloc(row_size);
     row->table = (struct ovsdb_table *) table;
     row->txn_row = NULL;
+    list_init(&row->src_refs);
+    list_init(&row->dst_refs);
     row->n_refs = 0;
     return row;
 }
@@ -77,8 +79,23 @@ ovsdb_row_destroy(struct ovsdb_row *row)
 {
     if (row) {
         const struct ovsdb_table *table = row->table;
+        struct ovsdb_weak_ref *weak, *next;
         const struct shash_node *node;
 
+        LIST_FOR_EACH_SAFE (weak, next, struct ovsdb_weak_ref, dst_node,
+                            &row->dst_refs) {
+            list_remove(&weak->src_node);
+            list_remove(&weak->dst_node);
+            free(weak);
+        }
+
+        LIST_FOR_EACH_SAFE (weak, next, struct ovsdb_weak_ref, src_node,
+                            &row->src_refs) {
+            list_remove(&weak->src_node);
+            list_remove(&weak->dst_node);
+            free(weak);
+        }
+
         SHASH_FOR_EACH (node, &table->schema->columns) {
             const struct ovsdb_column *column = node->data;
             ovsdb_datum_destroy(&row->fields[column->index], &column->type);
@@ -160,7 +177,7 @@ ovsdb_row_update_columns(struct ovsdb_row *dst,
 
 struct ovsdb_error *
 ovsdb_row_from_json(struct ovsdb_row *row, const struct json *json,
-                    const struct ovsdb_symbol_table *symtab,
+                    struct ovsdb_symbol_table *symtab,
                     struct ovsdb_column_set *included)
 {
     struct ovsdb_table_schema *schema = row->table->schema;