When adding a callback to an FD stream, we take an extra reference
on the virStreamPtr instance. We forgot to registered a free function
with the callback, so when the callback was removed, the extra
reference held on virStreamPtr was not released.
* src/fdstream.c: Use a free callback to release reference on
virStreamPtr when removing callback
---
src/fdstream.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/src/fdstream.c b/src/fdstream.c
index 182b6fa..54f8198 100644
--- a/src/fdstream.c
+++ b/src/fdstream.c
@@ -171,6 +171,13 @@ static void virFDStreamEvent(int watch ATTRIBUTE_UNUSED,
}
}
+static void virFDStreamCallbackFree(void *opaque)
+{
+ virStreamPtr st = opaque;
+ virStreamFree(st);
+}
+
+
static int
virFDStreamAddCallback(virStreamPtr st,
int events,
@@ -198,7 +205,7 @@ virFDStreamAddCallback(virStreamPtr st,
events,
virFDStreamEvent,
st,
- NULL)) < 0) {
+ virFDStreamCallbackFree)) < 0) {
streamsReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("cannot register file watch on
stream"));
goto cleanup;
--
1.7.4.4