Fix the missing return value checks on hash_remove() and hash_add() by replacing the calls with an single hash_add() call with the replace parameters set to true so that is can't fail. Then just ASSERT() that this is indeed the case.
This also replaces the other add/remove combinations with a single add-replace, because that should be slightly faster (and this is in the 'hot path'). Signed-off-by: Steffan Karger <stef...@karger.me> --- src/openvpn/multi.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c index 93a554d..a834e94 100644 --- a/src/openvpn/multi.c +++ b/src/openvpn/multi.c @@ -2320,9 +2320,6 @@ void multi_process_float (struct multi_context* m, struct multi_instance* mi) mroute_addr_print (&mi->real, &gc), print_link_socket_actual (&m->top.c2.from, &gc)); - ASSERT (hash_remove(m->hash, &mi->real)); - ASSERT (hash_remove(m->iter, &mi->real)); - /* change external network address of the remote peer */ mi->real = real; generate_prefix (mi); @@ -2336,12 +2333,11 @@ void multi_process_float (struct multi_context* m, struct multi_instance* mi) tls_update_remote_addr (mi->context.c2.tls_multi, &mi->context.c2.from); - ASSERT (hash_add (m->hash, &mi->real, mi, false)); - ASSERT (hash_add (m->iter, &mi->real, mi, false)); + ASSERT (hash_add (m->hash, &mi->real, mi, true)); + ASSERT (hash_add (m->iter, &mi->real, mi, true)); #ifdef MANAGEMENT_DEF_AUTH - hash_remove (m->cid_hash, &mi->context.c2.mda_context.cid); - hash_add (m->cid_hash, &mi->context.c2.mda_context.cid, mi, false); + ASSERT (hash_add (m->cid_hash, &mi->context.c2.mda_context.cid, mi, true)); #endif done: -- 2.7.4 ------------------------------------------------------------------------------ Developer Access Program for Intel Xeon Phi Processors Access to Intel Xeon Phi processor-based developer platforms. With one year of Intel Parallel Studio XE. Training and support from Colfax. Order your platform today. http://sdm.link/xeonphi _______________________________________________ Openvpn-devel mailing list Openvpn-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openvpn-devel