fixed race condition in the signalling between the rx and tx threads