author | Florian Forster <octo@collectd.org> | |
Fri, 11 Jan 2013 10:30:14 +0000 (11:30 +0100) | ||
committer | Florian Forster <octo@collectd.org> | |
Fri, 11 Jan 2013 10:30:14 +0000 (11:30 +0100) | ||
commit | 3c48e21e94c3d37f18796c8f9fc3ecb5e4b10ccd | |
tree | 91470fdf1f376047def9f419b408e3d79361b7dc | tree | snapshot |
parent | e0528dcc89bfc6fdb467f3add447c1778ad069d9 | commit | diff |
riemann plugin: Fix a double-free issue with the shared structure.
The reference to the riemann_host structure is shared between the write
and the notification callback. Upon exit, riemann_free() is called twice,
via the user_data_t structure passed to the register functions. Previously
this would have caused a double-free, which is unacceptable.
This patch introduces a reference counter and will only free the structure
(and close the socket) when the last reference is freed.
The locking has been moved out of the riemann_connect() function and into
the riemann_send() function. It is unlikely, but not impossible that two
threads interfere with each other when writing to the socket.
The reference to the riemann_host structure is shared between the write
and the notification callback. Upon exit, riemann_free() is called twice,
via the user_data_t structure passed to the register functions. Previously
this would have caused a double-free, which is unacceptable.
This patch introduces a reference counter and will only free the structure
(and close the socket) when the last reference is freed.
The locking has been moved out of the riemann_connect() function and into
the riemann_send() function. It is unlikely, but not impossible that two
threads interfere with each other when writing to the socket.
src/riemann.c | diff | blob | history |