From eca0cebba197edbc6aa452c86e8019ab8b955c81 Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Tue, 15 Mar 2011 18:20:46 +0000 Subject: libxl: Make all hidden/static functions take a gc not a ctx Also ensure that static and hidden functions use the libxl__ prefix not just libxl_ (in the case of static functions only when they use a libxl prefix to start with). This follows the policy described in libxl.h "libxl memory management". Based on a manual audit of: grep ^static tools/libxl/libxl*.[ch]| grep libxl_ctx grep libxl__ tools/libxl/*.h| grep libxl_ctx Signed-off-by: Ian Campbell Committed-by: Ian Jackson --- tools/libxl/libxl_exec.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'tools/libxl/libxl_exec.c') diff --git a/tools/libxl/libxl_exec.c b/tools/libxl/libxl_exec.c index e770fd3e09..a72cb83bee 100644 --- a/tools/libxl/libxl_exec.c +++ b/tools/libxl/libxl_exec.c @@ -91,12 +91,13 @@ void libxl_report_child_exitstatus(libxl_ctx *ctx, } } -int libxl__spawn_spawn(libxl_ctx *ctx, +int libxl__spawn_spawn(libxl__gc *gc, libxl__device_model_starting *starting, const char *what, void (*intermediate_hook)(void *for_spawn, pid_t innerchild)) { + libxl_ctx *ctx = libxl__gc_owner(gc); pid_t child, got; int status; pid_t intermediate; @@ -138,11 +139,12 @@ int libxl__spawn_spawn(libxl_ctx *ctx, ? WTERMSIG(status)+128 : -1); } -static void report_spawn_intermediate_status(libxl_ctx *ctx, - libxl__spawn_starting *for_spawn, - int status) +static void report_spawn_intermediate_status(libxl__gc *gc, + libxl__spawn_starting *for_spawn, + int status) { if (!WIFEXITED(status)) { + libxl_ctx *ctx = libxl__gc_owner(gc); char *intermediate_what; /* intermediate process did the logging itself if it exited */ if ( asprintf(&intermediate_what, @@ -154,9 +156,10 @@ static void report_spawn_intermediate_status(libxl_ctx *ctx, } } -int libxl__spawn_detach(libxl_ctx *ctx, +int libxl__spawn_detach(libxl__gc *gc, libxl__spawn_starting *for_spawn) { + libxl_ctx *ctx = libxl__gc_owner(gc); int r, status; pid_t got; int rc = 0; @@ -175,7 +178,7 @@ int libxl__spawn_detach(libxl_ctx *ctx, got = call_waitpid(ctx->waitpid_instead, for_spawn->intermediate, &status, 0); assert(got == for_spawn->intermediate); if (!(WIFSIGNALED(status) && WTERMSIG(status) == SIGKILL)) { - report_spawn_intermediate_status(ctx, for_spawn, status); + report_spawn_intermediate_status(gc, for_spawn, status); rc = ERROR_FAIL; } for_spawn->intermediate = 0; @@ -187,8 +190,9 @@ int libxl__spawn_detach(libxl_ctx *ctx, return rc; } -int libxl__spawn_check(libxl_ctx *ctx, void *for_spawn_void) +int libxl__spawn_check(libxl__gc *gc, void *for_spawn_void) { + libxl_ctx *ctx = libxl__gc_owner(gc); libxl__spawn_starting *for_spawn = for_spawn_void; pid_t got; int status; @@ -200,7 +204,7 @@ int libxl__spawn_check(libxl_ctx *ctx, void *for_spawn_void) if (!got) return 0; assert(got == for_spawn->intermediate); - report_spawn_intermediate_status(ctx, for_spawn, status); + report_spawn_intermediate_status(gc, for_spawn, status); for_spawn->intermediate = 0; return ERROR_FAIL; -- cgit v1.2.3