cleanup + debug logging
loop based on isClosed to accomodate SSL sockets
patch by Mikhail Stepura; reviewed by jbellis for CASSANDRA-6349