Skip to content

Commit

Permalink
[MXCHIP] add debug log for http_client_free stuck
Browse files Browse the repository at this point in the history
  • Loading branch information
mxchipwanges committed Mar 22, 2024
1 parent 4247fce commit b4f98ee
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 5 deletions.
6 changes: 6 additions & 0 deletions src/core/aio.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,13 @@ nni_aio_fini(nni_aio *aio)
// the task. And unlike aio_stop, we don't want to wait
// for the task. (Because we implicitly do task_fini.)
// We also wait if the aio is being expired.
log_trace("***nni_mtx_lock");
nni_mtx_lock(&eq->eq_mtx);
aio->a_stop = true;
while (aio->a_expiring) {
nni_cv_wait(&eq->eq_cv);
}
log_trace("***nni_aio_expire_rm");
nni_aio_expire_rm(aio);
fn = aio->a_cancel_fn;
arg = aio->a_cancel_arg;
Expand All @@ -135,10 +137,13 @@ nni_aio_fini(nni_aio *aio)
nni_mtx_unlock(&eq->eq_mtx);

if (fn != NULL) {
log_trace("***nni_aio_fini fn");
fn(aio, arg, NNG_ECLOSED);
}

log_trace("***nni_task_fini start");
nni_task_fini(&aio->a_task);
log_trace("***nni_task_fini end");
}

int
Expand All @@ -159,6 +164,7 @@ nni_aio_free(nni_aio *aio)
{
if (aio != NULL) {
nni_aio_fini(aio);
log_trace("***NNI_FREE_STRUCT");
NNI_FREE_STRUCT(aio);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/sp/protocol/mqtt/auth_http.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ send_request(conf_auth_http *conf, conf_auth_http_req *conf_req,
}
if (client) {
log_trace("nng_http_client_free start");
nng_http_client_free(client);
nng_http_client_free(client); // TODO
log_trace("nng_http_client_free end");
}
if (req) {
Expand Down
4 changes: 4 additions & 0 deletions src/supplemental/http/http_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,13 @@ http_dial_cb(void *arg)
void
nni_http_client_fini(nni_http_client *c)
{
log_trace("***nni_aio_free");
nni_aio_free(c->aio);
log_trace("***nng_stream_dialer_free");
nng_stream_dialer_free(c->dialer);
log_trace("***nni_mtx_fini");
nni_mtx_fini(&c->mtx);
log_trace("***NNI_FREE_STRUCT");
NNI_FREE_STRUCT(c);
}

Expand Down
8 changes: 4 additions & 4 deletions src/supplemental/http/http_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -674,10 +674,10 @@ nni_http_conn_fini(nni_http_conn *conn)
{
log_debug("**********nni_http_conn_fini conn->sock %p !", conn->sock);

// nni_aio_stop(conn->wr_aio);
// log_debug("**********nni_http_conn_fini nni_aio_stop (conn->wr_aio %p) !",conn->wr_aio);
// nni_aio_stop(conn->rd_aio);
// log_debug("**********nni_http_conn_fini nni_aio_stop (conn->rd_aio %p) !",conn->rd_aio);
nni_aio_stop(conn->wr_aio);
log_debug("**********nni_http_conn_fini nni_aio_stop (conn->wr_aio %p) !",conn->wr_aio);
nni_aio_stop(conn->rd_aio);
log_debug("**********nni_http_conn_fini nni_aio_stop (conn->rd_aio %p) !",conn->rd_aio);

nni_mtx_lock(&conn->mtx);
http_close(conn);
Expand Down
7 changes: 7 additions & 0 deletions src/supplemental/tls/tls_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -675,15 +675,22 @@ tls_cancel(nni_aio *aio, void *arg, int rv)
tls_conn *conn = arg;
log_debug("*** tls_cancel: conn %p, rv %d", conn, rv);
nni_mtx_lock(&conn->lock);
log_trace("***nni_list_first");
if (aio == nni_list_first(&conn->recv_queue)) {
log_trace("***nni_aio_abort tcp_recv");
nni_aio_abort(&conn->tcp_recv, rv);
} else if (aio == nni_list_first(&conn->send_queue)) {
log_trace("***nni_aio_abort tcp_send");
nni_aio_abort(&conn->tcp_send, rv);
} else if (nni_aio_list_active(aio)) {
log_trace("***nni_aio_list_remove");
nni_aio_list_remove(aio);
log_trace("***nni_aio_finish_error");
nni_aio_finish_error(aio, rv);
}
log_trace("***nni_mtx_unlock");
nni_mtx_unlock(&conn->lock);
log_trace("***nni_mtx_unlock end");
}

// tls_send implements the upper layer stream send operation.
Expand Down

0 comments on commit b4f98ee

Please sign in to comment.