Fix race condition on exit of trpc threads
authorJennifer Richards <jennifer@painless-security.com>
Fri, 27 Apr 2018 01:46:36 +0000 (21:46 -0400)
committerJennifer Richards <jennifer@painless-security.com>
Fri, 27 Apr 2018 01:46:36 +0000 (21:46 -0400)
commit9caf4a7734e083cd41740c90dcb84ff8a321f015
tree3af1909e8b81266472da9da1ba48bac7d1f0c78e
parent77b6d2f32dbcf03d7119170949544966e9b71a9c
Fix race condition on exit of trpc threads

The messaging between the main thread and the trpc (outgoing connection)
threads allowed the trpc data to be cleaned up before the message queue
was empty, causing incorrect mutex behavior and seg faults.

This is (I hope!) solved adding an additional shutdown phase in which
the main thread indicates that it has recognized that the trpc thread
is done and that the trpc thread can safely exit.

So far, I have not seen a failure of the system to handle a peer
disconnecting. Prior to these changes, it failed every time with my
current setup.
include/tr_trp.h
include/trp_internal.h
tr/tr_trp.c
trp/trp_conn.c
trp/trpc.c
trp/trps.c