[Libguestfs] [PATCH] Fix code which looked for leaked FDs between each command.
Richard W.M. Jones
rjones at redhat.com
Thu Sep 17 16:49:55 UTC 2009
--
Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones
libguestfs lets you edit virtual machines. Supports shell scripting,
bindings from many languages. http://et.redhat.com/~rjones/libguestfs/
See what it can do: http://et.redhat.com/~rjones/libguestfs/recipes.html
-------------- next part --------------
>From d5fad33b4eaa39722ea1dc96de9446ffc4805e01 Mon Sep 17 00:00:00 2001
From: Richard Jones <rjones at trick.home.annexia.org>
Date: Thu, 17 Sep 2009 16:44:20 +0100
Subject: [PATCH 1/3] Fix code which looked for leaked FDs between each command.
This code was not checking the return value from system()
so it failed if uncommented. Add ignore_value() around the
call to system. However, leave the code still disabled.
---
daemon/m4/gnulib-cache.m4 | 3 ++-
daemon/proto.c | 8 ++++----
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/daemon/m4/gnulib-cache.m4 b/daemon/m4/gnulib-cache.m4
index ea499d8..bd6cf61 100644
--- a/daemon/m4/gnulib-cache.m4
+++ b/daemon/m4/gnulib-cache.m4
@@ -15,12 +15,13 @@
# Specification in the form of a command-line invocation:
-# gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --with-tests --no-libtool --macro-prefix=gl hash manywarnings warnings
+# gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --with-tests --no-libtool --macro-prefix=gl hash ignore-value manywarnings warnings
# Specification in the form of a few gnulib-tool.m4 macro invocations:
gl_LOCAL_DIR([])
gl_MODULES([
hash
+ ignore-value
manywarnings
warnings
])
diff --git a/daemon/proto.c b/daemon/proto.c
index c0e3927..c22bbee 100644
--- a/daemon/proto.c
+++ b/daemon/proto.c
@@ -29,6 +29,8 @@
#include <rpc/types.h>
#include <rpc/xdr.h>
+#include "ignore-value.h"
+
#include "daemon.h"
#include "../src/guestfs_protocol.h"
@@ -53,13 +55,11 @@ main_loop (int _sock)
sock = _sock;
for (;;) {
-#if 0
/* Most common errors are leaked memory and leaked file descriptors,
* so run this between each command:
*/
- if (verbose)
- system ("ls -l /proc/self/fd");
-#endif
+ if (verbose && 0)
+ ignore_value (system ("ls -l /proc/self/fd"));
/* Read the length word. */
if (xread (sock, lenbuf, 4) == -1)
--
1.6.2.5
More information about the Libguestfs
mailing list