Skip to content

Commit c6cd779

Browse files
committed
* FIX [pipe/core] free subinfol in transport
Signed-off-by: Jaylin <jaylin@emqx.io>
1 parent dadcade commit c6cd779

File tree

2 files changed

+34
-13
lines changed

2 files changed

+34
-13
lines changed

src/core/pipe.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,19 @@ pipe_destroy(void *arg)
6060
p->p_tran_ops.p_stop(p->p_tran_data);
6161
}
6262

63-
// Freed here
64-
struct subinfo *s = NULL;
65-
if (p->subinfol != NULL) {
66-
while (!nni_list_empty(p->subinfol)) {
67-
s = nni_list_last(p->subinfol);
68-
if (s && s->topic != NULL) {
69-
nni_list_remove(p->subinfol, s);
70-
nng_free(s->topic, strlen(s->topic));
71-
nng_free(s, sizeof(*s));
72-
}
73-
}
74-
nni_free(p->subinfol, sizeof(nni_list));
75-
}
63+
// // Freed here
64+
// struct subinfo *s = NULL;
65+
// if (p->subinfol != NULL) {
66+
// while (!nni_list_empty(p->subinfol)) {
67+
// s = nni_list_last(p->subinfol);
68+
// if (s && s->topic != NULL) {
69+
// nni_list_remove(p->subinfol, s);
70+
// nng_free(s->topic, strlen(s->topic));
71+
// nng_free(s, sizeof(*s));
72+
// }
73+
// }
74+
// nni_free(p->subinfol, sizeof(nni_list));
75+
// }
7676

7777
#ifdef NNG_ENABLE_STATS
7878
nni_stat_unregister(&p->st_root);

src/sp/transport/mqtt/broker_tcp.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,20 @@ tcptran_pipe_close(void *arg)
132132
}
133133
nni_mtx_lock(&p->mtx);
134134
p->closed = true;
135+
// Freed here
136+
struct subinfo *s = NULL;
137+
if (p->npipe->subinfol != NULL) {
138+
while (!nni_list_empty(p->npipe->subinfol)) {
139+
s = nni_list_last(p->npipe->subinfol);
140+
if (s && s->topic != NULL) {
141+
nni_list_remove(p->npipe->subinfol, s);
142+
nng_free(s->topic, strlen(s->topic));
143+
nng_free(s, sizeof(*s));
144+
}
145+
}
146+
nni_free(p->npipe->subinfol, sizeof(nni_list));
147+
p->npipe->subinfol = NULL;
148+
}
135149
nni_mtx_unlock(&p->mtx);
136150

137151
nng_stream_close(p->conn);
@@ -1564,6 +1578,13 @@ tcptran_pipe_send(void *arg, nni_aio *aio)
15641578
uint8_t qos_pac = 0, qos = 0;
15651579
uint16_t packetid;
15661580
char *pld_pac = NULL;
1581+
1582+
// nni_msg_free(msg);
1583+
// nni_mtx_unlock(&p->mtx);
1584+
// nni_aio_set_msg(aio, NULL);
1585+
// nni_aio_finish(aio, 0, 0);
1586+
// return;
1587+
15671588
if (nni_msg_get_type(msg) == CMD_PUBLISH) {
15681589
qos_pac = nni_msg_get_pub_qos(msg);
15691590
pld_pac = nni_msg_get_pub_topic(msg, &tlen_pac);

0 commit comments

Comments
 (0)