Deadlock on close() socket bugfix

close() and receive() were using the same lock, which provoked a deadlock when a
thread was waiting a blocking receive() and another wanted to close() the
socket.