Some thread safety related fixes to TCP connections in net_crypto.

Added a recursive mutex to fix possible thread issues when the A/V
thread sends data at the same time as the main thread.