python: Avoid race condition between disconnect probe thread and disconnect function

There is a chance that the disconnect function locks the socket_lock and
tires to join the disconnect probe thread while the disconnect probe thread
is about to lock the socket_lock. This results in a dead lock.

Avoid this problem by not locking the socket_lock in the disconnect probe
thread. This locking was not necessary as the disconnect probe thread only
exists while the socket is valid.

Also add a socket_send_lock to the socket for serializing send calls, which was
realized by the socket_lock before.
ruby: Avoid race condition between disconnect probe thread and disconnect function

There is a chance that the disconnect function locks the socket_mutex and
tires to join the disconnect probe thread while the disconnect probe thread
is about to lock the socket_mutex. This results in a dead lock.

Avoid this problem by not locking the socket_mutex in the disconnect probe
thread. This locking was not necessary as the disconnect probe thread only
exists while the socket is valid.

Also add a socket_send_mutex to the socket for serializing send calls, which was
realized by the socket_mutex before.