Skip to content

Commit 5e8067c

Browse files
committed
Core - destroy leftover periodic messages on plugin destruction
This fixes a memory leak and a warning that occured on termination because of unprocessed periodic messages still being left in the feedback pipe. We exhaust the pipe and destroy any leftover messages now.
1 parent ab3dd90 commit 5e8067c

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/core/fpipe.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,19 @@ ipx_fpipe_create()
9393
void
9494
ipx_fpipe_destroy(ipx_fpipe_t *fpipe)
9595
{
96-
if (fpipe->cnt != 0) {
96+
// Destroy any leftover periodic messages
97+
ipx_msg_t *msg;
98+
int err_cnt = 0;
99+
while ((msg = ipx_fpipe_read(fpipe)) != NULL) {
100+
if (ipx_msg_get_type(msg) != IPX_MSG_PERIODIC) {
101+
err_cnt++;
102+
}
103+
ipx_msg_destroy(msg);
104+
}
105+
106+
if (err_cnt > 0) {
97107
IPX_WARNING(fpipe_str, "Destroying of a pipe that still contains %" PRIu32 " unprocessed "
98-
"message(s)!", fpipe->cnt);
108+
"non-periodic message(s)!", fpipe->cnt);
99109
}
100110

101111
// Close the pipe and destroy the structure

0 commit comments

Comments
 (0)