Skip to content

Commit

Permalink
[MXCHIP] Enable disconnect msg for AO-SGW7000
Browse files Browse the repository at this point in the history
  • Loading branch information
mxchipwanges committed Feb 5, 2024
1 parent 3aa8435 commit 940d0d0
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/sp/protocol/mqtt/nmq_mqtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,9 @@ nano_pipe_close(void *arg)
nni_msg *msg;
nni_pipe *npipe = p->pipe;
char *clientid = NULL;
#ifdef CONFIG_MXCHIP
int ret = 0;
#endif

log_trace(" ############## nano_pipe_close ############## ");
if (npipe->cache == true) {
Expand All @@ -833,9 +836,14 @@ nano_pipe_close(void *arg)
if (new_pipe == npipe) {
nni_id_set(&s->cached_sessions, npipe->p_id, p);
nni_mtx_lock(&p->lk);
#ifdef CONFIG_MXCHIP
// enable disconnect msg for AO-SGW7000 by wanges@202402005
p->event = true;
#else
// set event to false avoid of sending the
// disconnecting msg
p->event = false;
#endif
npipe->cache = true;
// set clean start to 1, prevent caching session twice
p->conn_param->clean_start = 1;
Expand All @@ -844,9 +852,16 @@ nano_pipe_close(void *arg)
nni_list_remove(&s->recvpipes, p);
}
nano_nni_lmq_flush(&p->rlmq, false);
#ifdef CONFIG_MXCHIP
nni_mtx_unlock(&p->lk);
ret = -1;
log_debug("*** mxchip enabled: send disconnect msg even clean_start=0 ***");
goto send_disconnect_msg;
#else
nni_mtx_unlock(&s->lk);
nni_mtx_unlock(&p->lk);
return -1;
#endif
}
// have to stop aio timer first, otherwise we hit null qos_db
nni_aio_stop(&p->aio_timer);
Expand All @@ -866,12 +881,19 @@ nano_pipe_close(void *arg)
// TODO send disconnect msg to client if needed.
// depends on MQTT V5 reason code
// create disconnect event msg
#ifdef CONFIG_MXCHIP
send_disconnect_msg:
#endif
if (p->event) {
msg =
nano_msg_notify_disconnect(p->conn_param, p->reason_code);
if (msg == NULL) {
nni_mtx_unlock(&s->lk);
#ifdef CONFIG_MXCHIP
return ret;
#else
return 0;
#endif
}
nni_msg_set_conn_param(msg, p->conn_param);
// clone for notification pub
Expand All @@ -887,7 +909,11 @@ nano_pipe_close(void *arg)
nni_mtx_unlock(&s->lk);
nni_aio_set_msg(aio, msg);
nni_aio_finish(aio, 0, nni_msg_len(msg));
#ifdef CONFIG_MXCHIP
return ret;
#else
return 0;
#endif
} else {
// no enough ctx, so cache to waitlmq
// free conn param when discard waitlmq
Expand All @@ -903,7 +929,11 @@ nano_pipe_close(void *arg)
}
}
nni_mtx_unlock(&s->lk);
#ifdef CONFIG_MXCHIP
return ret;
#else
return 0;
#endif
}

static void
Expand Down

0 comments on commit 940d0d0

Please sign in to comment.