Fix some bugs in the SIP tcp helper thread.