diff --git a/source/libs/transport/src/thttp.c b/source/libs/transport/src/thttp.c index a58363276526dccd612346dc3f1b0063fc91d967..92989a45f5cb61600aa45c599ae919e95313c24b 100644 --- a/source/libs/transport/src/thttp.c +++ b/source/libs/transport/src/thttp.c @@ -148,14 +148,22 @@ static FORCE_INLINE void clientRecvCb(uv_stream_t* handle, ssize_t nread, const } else { uTrace("http-report succ to recv %d bytes", (int32_t)nread); } - uv_close((uv_handle_t*)&cli->tcp, clientCloseCb); + if (!uv_is_closing((uv_handle_t*)&cli->tcp)) { + uv_close((uv_handle_t*)&cli->tcp, clientCloseCb); + } else { + destroyHttpClient(cli); + } } static void clientSentCb(uv_write_t* req, int32_t status) { SHttpClient* cli = req->data; if (status != 0) { terrno = TAOS_SYSTEM_ERROR(status); uError("http-report failed to send data %s", uv_strerror(status)); - uv_close((uv_handle_t*)&cli->tcp, clientCloseCb); + if (!uv_is_closing((uv_handle_t*)&cli->tcp)) { + uv_close((uv_handle_t*)&cli->tcp, clientCloseCb); + } else { + destroyHttpClient(cli); + } return; } else { uTrace("http-report succ to send data"); @@ -176,7 +184,11 @@ static void clientConnCb(uv_connect_t* req, int32_t status) { if (status != 0) { terrno = TAOS_SYSTEM_ERROR(status); uError("http-report failed to conn to server, reason:%s, dst:%s:%d", uv_strerror(status), cli->addr, cli->port); - uv_close((uv_handle_t*)&cli->tcp, clientCloseCb); + if (!uv_is_closing((uv_handle_t*)&cli->tcp)) { + uv_close((uv_handle_t*)&cli->tcp, clientCloseCb); + } else { + destroyHttpClient(cli); + } return; } status = uv_write(&cli->req, (uv_stream_t*)&cli->tcp, cli->wbuf, 2, clientSentCb);