make receive socket to timeout in a second

Reported-by: Richard Davies <richard.davies@lastminute.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
fix thread locking problem

The lock that this commit removes made program to single thread.

Reported-by: Richard Davies <richard.davies@lastminute.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>