Skip to content

Commit 6f7f8df

Browse files
committed
Merge branch 'periodic-message-fix-leak' into 'master'
Core - destroy leftover periodic messages on plugin destruction See merge request monitoring/ipfixcol2!25
2 parents ab3dd90 + 5e8067c commit 6f7f8df

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)