added clearing ring before calling handle_socket_errno which logs and exits in this case
added NDEBUG to turn off assert