Skip to content

Commit

Permalink
* FIX [mqtt/transport] fix #22 alloc tmaio before nego
Browse files Browse the repository at this point in the history
  • Loading branch information
JaylinYu authored and alvin1221 committed Feb 14, 2022
1 parent 3dee579 commit d187ba1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/mqtt/transport/tcp/mqtt_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ mqtt_tcptran_pipe_init(void *arg, nni_pipe *npipe)
p->npipe = npipe;

nni_lmq_init(&p->rslmq, 16);
nni_aio_init(&p->tmaio, mqtt_pipe_timer_cb, p);
p->busy = false;
nni_sleep_aio(p->keepalive, &p->tmaio);
return (0);
Expand Down Expand Up @@ -246,6 +245,8 @@ mqtt_tcptran_pipe_alloc(mqtt_tcptran_pipe **pipep)
return (NNG_ENOMEM);
}
nni_mtx_init(&p->mtx);
// alloc timer aio first, but only start it when nego is completed
nni_aio_init(&p->tmaio, mqtt_pipe_timer_cb, p);
if (((rv = nni_aio_alloc(&p->txaio, mqtt_tcptran_pipe_send_cb, p)) !=
0) ||
((rv = nni_aio_alloc(&p->rxaio, mqtt_tcptran_pipe_recv_cb, p)) !=
Expand Down

0 comments on commit d187ba1

Please sign in to comment.