Fixed dangling pointerin close_connection
inline method refactoring