help
help copied to clipboard
Release uv_tcp_t in uv_close callback will cause loop to crash
- Version: 1.27.0
- Platform: Windows
问题复现: 当关闭一个客户端连接后,试图在关闭回调里面释放uv_tcp_t时,会造成uv_process_reqs函数里面的req为0xdddddddd,当服务器关闭连接时,也就是被动关闭,则不会引起此问题
Problem recurrence: When closing a client connection, trying to release uv_tcp_t in the close callback will cause the req in the uv_process_reqs function to be 0xdddddddd. When the server closes the connection, it is passively closed, which will not cause this problem.
int CUvTcpClient::close() { if (connected_status__ && (tcp_client__->flags & UV_HANDLE_CLOSING) == 0) { uv_close((uv_handle_t*)tcp_client__, [](uv_handle_t* handle) { ((CUvTcpClient*)handle->data)->inner_on_close(); //close callback }); }
return 0;
}
void CUvTcpClient::inner_on_close() { connected_status__ = false; if (tcp_client__) { free(tcp_client__); //free , uv_process_reqs func req is 0xdddddddd tcp_client__ = NULL; }
on_close();
}