If two UDP datagrams arrive from the same port, both threads will
contend for the new_flow_lock mutex which is after the check to see
if a hashtable record exists. Therefore both threads will create
a hashtable entry for the same flow and bind 2 sockets.
We wish to keep the fast-path (already-established connections) fast,
so rather than hold the mutex for the whole function we instead
re-check the hashtable after acquiring the mutex.
If two UDP datagrams arrive from the same port, both threads will contend for the
new_flow_lock
mutex which is after the check to see if a hashtable record exists. Therefore both threads will create a hashtable entry for the same flow and bind 2 sockets.We wish to keep the fast-path (already-established connections) fast, so rather than hold the mutex for the whole function we instead re-check the hashtable after acquiring the mutex.
Signed-off-by: David Scott dave.scott@docker.com