From: "Richard W.M. Jones" <rjones(a)redhat.com>
Using ./configure --enable-valgrind-daemon breaks valgrinding of the
library because guestfs_close wouldn't call guestfs_shutdown in that
case, resulting in some resources owned by the backend being leaked.
After this commit, --enable-valgrind-daemon will shut down the handle
normally.
This updates commit 55e3b8711f340a2f8bdb8ee8ff99deb40b4e9108.
(cherry picked from commit 94872348e852a9bdfa4d170b0f238d796789c73a)
---
src/handle.c | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/src/handle.c b/src/handle.c
index b4291e8..dc2b15b 100644
--- a/src/handle.c
+++ b/src/handle.c
@@ -294,16 +294,8 @@ guestfs_close (guestfs_h *g)
debug (g, "closing guestfs handle %p (state %d)", g, g->state);
- /* If we are valgrinding the daemon, then we *don't* want to kill
- * the subprocess because we want the final valgrind messages sent
- * when we close sockets below. However for normal production use,
- * killing the subprocess is the right thing to do (in case the
- * daemon or qemu is not responding).
- */
-#ifndef VALGRIND_DAEMON
if (g->state != CONFIG)
shutdown_backend (g, 0);
-#endif
/* Run user close callbacks. */
guestfs___call_callbacks_void (g, GUESTFS_EVENT_CLOSE);
@@ -382,15 +374,16 @@ shutdown_backend (guestfs_h *g, int check_for_errors)
ret = -1;
}
+ /* Shut down the backend. */
+ if (g->backend_ops->shutdown (g, check_for_errors) == -1)
+ ret = -1;
+
/* Close sockets. */
if (g->conn) {
g->conn->ops->free_connection (g, g->conn);
g->conn = NULL;
}
- if (g->backend_ops->shutdown (g, check_for_errors) == -1)
- ret = -1;
-
guestfs___free_drives (g);
g->state = CONFIG;
--
1.8.3.1