hmap_remove(all_bfds, &bfd->node);
netdev_close(bfd->netdev);
free(bfd->name);
+ atomic_destroy(&bfd->ref_cnt);
free(bfd);
ovs_mutex_unlock(&mutex);
}
hmap_destroy(&cfm->remote_mps);
netdev_close(cfm->netdev);
free(cfm->rmps_array);
+
+ atomic_destroy(&cfm->extended);
+ atomic_destroy(&cfm->check_tnl_key);
+ atomic_destroy(&cfm->ref_cnt);
+
free(cfm);
}
hmap_destroy(&lacp->slaves);
list_remove(&lacp->node);
free(lacp->name);
+ atomic_destroy(&lacp->ref_cnt);
free(lacp);
ovs_mutex_unlock(&mutex);
}
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
bitmap_free(ml->flood_vlans);
ovs_rwlock_destroy(&ml->rwlock);
+ atomic_destroy(&ml->ref_cnt);
free(ml);
}
}
atomic_read(&rc->ref_cnt, &ref_cnt);
if (!ref_cnt) {
hmap_remove(&netdev_classes, &rc->hmap_node);
+ atomic_destroy(&rc->ref_cnt);
free(rc);
error = 0;
} else {
#define ATOMIC_VAR_INIT(VALUE) (VALUE)
#define atomic_init(OBJECT, VALUE) __c11_atomic_init(OBJECT, VALUE)
+#define atomic_destroy(OBJECT) ((void) (OBJECT))
/* Clang hard-codes these exact values internally but does not appear to
* export any names for them. */
\f
#define ATOMIC_VAR_INIT(VALUE) { .value = (VALUE) }
#define atomic_init(OBJECT, VALUE) ((OBJECT)->value = (VALUE), (void) 0)
+#define atomic_destroy(OBJECT) ((void) (OBJECT))
static inline void
atomic_thread_fence(memory_order order)
#define ATOMIC_VAR_INIT(VALUE) (VALUE)
#define atomic_init(OBJECT, VALUE) (*(OBJECT) = (VALUE), (void) 0)
+#define atomic_destroy(OBJECT) ((void) (OBJECT))
#define atomic_thread_fence __atomic_thread_fence
#define atomic_signal_fence __atomic_signal_fence
((OBJECT)->value = (VALUE), \
pthread_mutex_init(&(OBJECT)->mutex, NULL), \
(void) 0)
+#define atomic_destroy(OBJECT) \
+ (pthread_mutex_destroy(&(OBJECT)->mutex), \
+ (void) 0)
static inline void
atomic_thread_fence(memory_order order OVS_UNUSED)
* that.
*
*
- * Initialization
- * ==============
+ * Life Cycle
+ * ==========
*
* To initialize an atomic variable at its point of definition, use
* ATOMIC_VAR_INIT:
* ...
* atomic_init(&ai, 123);
*
+ * C11 does not hav an destruction function for atomic types, but some
+ * implementations of the OVS atomics do need them. Thus, the following
+ * function is provided for destroying non-static atomic objects (A is any
+ * atomic type):
+ *
+ * void atomic_destroy(A *object);
+ *
+ * Destroys 'object'.
+ *
*
* Barriers
* ========
list_remove(&stp->node);
ovs_mutex_unlock(&mutex);
free(stp->name);
+ atomic_destroy(&stp->ref_cnt);
free(stp);
}
}
free(bond->hash);
free(bond->name);
+ atomic_destroy(&bond->ref_cnt);
free(bond);
}
/*
- * Copyright (c) 2008, 2009, 2010, 2011 Nicira, Inc.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2013 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
atomic_sub(&netflow_count, 1, &orig);
collectors_destroy(nf->collectors);
ofpbuf_uninit(&nf->packet);
+ atomic_destroy(&nf->ref_cnt);
free(nf);
}
}
/*
- * Copyright (c) 2012 Nicira, Inc.
+ * Copyright (c) 2012, 2013 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
dpif_ipfix_clear(di);
dpif_ipfix_bridge_exporter_destroy(&di->bridge_exporter);
hmap_destroy(&di->flow_exporter_map);
+ atomic_destroy(&di->ref_cnt);
free(di);
ovs_mutex_unlock(&mutex);
}
dpif_sflow_del_port__(ds, dsp);
}
hmap_destroy(&ds->ports);
+ atomic_destroy(&ds->ref_cnt);
free(ds);
}
}
latch_destroy(&udpif->exit_latch);
seq_destroy(udpif->reval_seq);
seq_destroy(udpif->dump_seq);
+ atomic_destroy(&udpif->max_idle);
+ atomic_destroy(&udpif->flow_limit);
free(udpif);
}
/*
- * Copyright (c) 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
+ * Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc.
* Copyright (c) 2010 Jean Tourrilhes - HP-Labs.
*
* Licensed under the Apache License, Version 2.0 (the "License");
cls_rule_destroy(CONST_CAST(struct cls_rule *, &rule->cr));
rule_actions_unref(rule->actions);
ovs_mutex_destroy(&rule->mutex);
+ atomic_destroy(&rule->ref_count);
rule->ofproto->ofproto_class->rule_dealloc(rule);
}
atomic_sub(&actions->ref_count, 1, &orig);
if (orig == 1) {
+ atomic_destroy(&actions->ref_count);
free(actions->ofpacts);
free(actions);
} else {
oftable_disable_eviction(table);
classifier_destroy(&table->cls);
free(table->name);
+ atomic_destroy(&table->config);
}
/* Changes the name of 'table' to 'name'. If 'name' is NULL or the empty
ovs_assert(orig == 2); \
atomic_read(&x, &value); \
ovs_assert(value == 8); \
+ \
+ atomic_destroy(&x); \
}
static void