Skip to content

Commit

Permalink
[MXCHIP] debug auth_http 401 close issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mxchipwanges committed Mar 21, 2024
1 parent 870bb72 commit 7072cc0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/core/pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ nni_pipe_set_pid(nni_pipe *new_pipe, uint32_t id)
nni_mtx_unlock(&pipes_lk);
if (!p->cache || rv != 0) {
#ifdef CONFIG_MXCHIP
log_warn("*** kick old client %p hash %d", p, id);
log_warn("*** kick old client pipe(%p) client_id hash(%d)", p, id);
nano_pipe_event_disable(p->p_proto_data, true); // disable disconnect event if reconnect wes@240301
#endif
nni_pipe_close(p);
Expand Down
3 changes: 3 additions & 0 deletions src/sp/protocol/mqtt/auth_http.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ send_request(conf_auth_http *conf, conf_auth_http_req *conf_req,
nng_aio_wait(aio);
if ((rv = nng_aio_result(aio)) != 0) {
log_error("Connect failed: %s\n", nng_strerror(rv));
nng_aio_finish_sync(aio, rv);
goto out;
}

Expand All @@ -293,9 +294,11 @@ send_request(conf_auth_http *conf, conf_auth_http_req *conf_req,
nng_aio_set_timeout(aio, conf->timeout * 1000);
// TODO It could cause some problems.
nng_aio_wait(aio);
log_debug("auth_http req result %d", nng_aio_result(aio));

if ((rv = nng_aio_result(aio)) != 0) {
log_error("Write req failed: %s", nng_strerror(rv));
nng_aio_finish_sync(aio, rv);
goto out;
}

Expand Down
9 changes: 7 additions & 2 deletions src/sp/protocol/mqtt/nmq_mqtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,7 @@ nano_pipe_start(void *arg)
nni_pipe *npipe = p->pipe;

bool is_sqlite = s->conf->sqlite.enable;
uint32_t clientid_key;

log_trace(" ########## nano_pipe_start ########## ");

Expand Down Expand Up @@ -679,13 +680,17 @@ nano_pipe_start(void *arg)
log_warn("IPv6 address is not supported in event msg yet");
}

log_debug("client connected! addr [%s port [%d]\n",
p->conn_param->ip_addr_v4, addr.s_in.sa_port);
// log_debug("client connected! addr [%s port [%d]\n",
// p->conn_param->ip_addr_v4, addr.s_in.sa_port);

session_keeping:
// Clientid should not be NULL since broker will assign one
// TODO use p_id
clientid = (char *) conn_param_get_clientid(p->conn_param);
clientid_key = DJBHashn(clientid, strlen(clientid));
log_debug("client_id(%s, hash %d), username(%d), passwd(%s), clean_start(%d), keepalive(%d) connected! addr [%s port [%d]\n",
clientid, clientid_key, p->conn_param->username, p->conn_param->password, p->conn_param->clean_start, p->conn_param->keepalive_mqtt,
p->conn_param->ip_addr_v4, addr.s_in.sa_port);
if (!clientid) {
log_warn("NULL clientid found when try to restore session.");
nni_mtx_unlock(&s->lk);
Expand Down
7 changes: 7 additions & 0 deletions src/supplemental/http/http_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ http_close(nni_http_conn *conn)
// Call with lock held.
nni_aio *aio;

log_debug("**********http_close conn->sock %p !", conn->sock);

if (conn->closed) {
log_debug("**********conn->closed already true, return !!!");
return;
}

Expand Down Expand Up @@ -110,6 +113,7 @@ http_close(nni_http_conn *conn)
}

if (conn->sock != NULL) {
log_debug("**********nng_stream_close conn->sock %p !", conn->sock);
nng_stream_close(conn->sock);
}
}
Expand Down Expand Up @@ -665,12 +669,15 @@ nni_http_conn_setopt(nni_http_conn *conn, const char *name, const void *buf,
void
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);
nni_aio_stop(conn->rd_aio);

nni_mtx_lock(&conn->mtx);
http_close(conn);
if (conn->sock != NULL) {
log_debug("**********nng_stream_free conn->sock %p !", conn->sock);
nng_stream_free(conn->sock);
conn->sock = NULL;
}
Expand Down

0 comments on commit 7072cc0

Please sign in to comment.