While investigating issue 4046 I've noticed that in case of an error during the
SSL handshake that is used for the authentication of the replication session
the associated socket is not correctly closed by the replication code.
The socket therefore is left open and the associated resources are never free.
This change fix this problem.
It will not solve the root cause of the 4046 issue but will help to keep the server
running by avoiding to consume of the process resources.
The issue 3713 might also be related to this problem because the symptoms are
similar.