lib/ovsdb-map-op.c
/* Inserts 'map_op' into 'list'. Makes sure that any conflict with a previous
 * map operation is resolved, so only one map operation is possible on each key
 * per transactions. 'type' must be the type of the column over which the map
 * operation will be applied. */
Inserts 'map_op' into 'list'. Makes sure that any conflict with a previous
map operation is resolved, so only one map operation is possible on each key
per transactions. 'type' must be the type of the column over which the map
operation will be applied.
Inserts ' map_op ' into ' list ' . Makes sure that any conflict with a previous map operation is resolved so only one map operation is possible on each key per transactions . ' type ' must be the type of the column over which the map operation will be applied .
void
map_op_list_add(struct map_op_list *list, struct map_op *map_op,
                const struct ovsdb_type *type)
{
    size_t hash;
    struct map_op *prev_map_op;
    hash = ovsdb_atom_hash(&map_op->datum->keys[0], type->key.type, 0);
    prev_map_op = map_op_list_find(list, map_op, type, hash);
    if (prev_map_op == NULL){
        hmap_insert(&list->hmap, &map_op->node, hash);
    } else {
        if (prev_map_op->type == MAP_OP_INSERT &&
            map_op->type == MAP_OP_DELETE) {
            hmap_remove(&list->hmap, &prev_map_op->node);
            map_op_destroy(prev_map_op, type);
            map_op_destroy(map_op, type);
        } else {
            map_op_destroy_datum(prev_map_op, type);
            prev_map_op->type = map_op->type;
            prev_map_op->datum = map_op->datum;
            free(map_op);
        }
    }
}
void map_op_list_add ( struct map_op_list * list , struct map_op * map_op , const struct ovsdb_type * type ) { size_t hash ; struct map_op * prev_map_op ; hash = ovsdb_atom_hash ( & map_op -> datum -> keys [ 0 ] , type -> key . type , 0 ) ; prev_map_op = map_op_list_find ( list , map_op , type , hash ) ; if ( prev_map_op == NULL ) { hmap_insert ( & list -> hmap , & map_op -> node , hash ) ; } else { if ( prev_map_op -> type == MAP_OP_INSERT && map_op -> type == MAP_OP_DELETE ) { hmap_remove ( & list -> hmap , & prev_map_op -> node ) ; map_op_destroy ( prev_map_op , type ) ; map_op_destroy ( map_op , type ) ; } else { map_op_destroy_datum ( prev_map_op , type ) ; prev_map_op -> type = map_op -> type ; prev_map_op -> datum = map_op -> datum ; free ( map_op ) ; } } }
Inserts 'map_op' into 'list'.
Inserts ' map_op ' into ' list ' .
/* Check if there is a previous update with the same key. */ /* These operations cancel each other out. */ /* For any other case, the new update operation replaces
             * the previous update operation. */