[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 1/3] libxl: event system: pass gc, not just ctx, to internal sigchld manipulators
We are going to want the gc for libxl__ev_fd_register. No functional change in this patch. Simply change the argument types, and the actual arguments from ctx to gc. Inside these functions, use CTX (the macro which uses gc) rather than the old formal parameter ctx. Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx> Cc: Ian Campbell <ian.campbell@xxxxxxxxxx> --- tools/libxl/libxl.c | 2 +- tools/libxl/libxl_fork.c | 36 ++++++++++++++++++------------------ tools/libxl/libxl_internal.h | 4 ++-- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 0de1112..2ebba98 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -171,7 +171,7 @@ int libxl_ctx_free(libxl_ctx *ctx) /* If we have outstanding children, then the application inherits * them; we wish the application good luck with understanding * this if and when it reaps them. */ - libxl__sigchld_removehandler(ctx); + libxl__sigchld_removehandler(gc); if (ctx->sigchld_selfpipe[0] >= 0) { close(ctx->sigchld_selfpipe[0]); diff --git a/tools/libxl/libxl_fork.c b/tools/libxl/libxl_fork.c index b6f0b2d..ae6184c 100644 --- a/tools/libxl/libxl_fork.c +++ b/tools/libxl/libxl_fork.c @@ -175,23 +175,23 @@ static void sigchld_removehandler_core(void) sigchld_owner = 0; } -void libxl__sigchld_removehandler(libxl_ctx *ctx) /* non-reentrant */ +void libxl__sigchld_removehandler(libxl__gc *gc) /* non-reentrant */ { atfork_lock(); - if (sigchld_owner == ctx) + if (sigchld_owner == CTX) sigchld_removehandler_core(); atfork_unlock(); } -int libxl__sigchld_installhandler(libxl_ctx *ctx) /* non-reentrant */ +int libxl__sigchld_installhandler(libxl__gc *gc) /* non-reentrant */ { int r, rc; - if (ctx->sigchld_selfpipe[0] < 0) { - r = pipe(ctx->sigchld_selfpipe); + if (CTX->sigchld_selfpipe[0] < 0) { + r = pipe(CTX->sigchld_selfpipe); if (r) { - ctx->sigchld_selfpipe[0] = -1; - LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, + CTX->sigchld_selfpipe[0] = -1; + LIBXL__LOG_ERRNO(CTX, LIBXL__LOG_ERROR, "failed to create sigchld pipe"); rc = ERROR_FAIL; goto out; @@ -199,11 +199,11 @@ int libxl__sigchld_installhandler(libxl_ctx *ctx) /* non-reentrant */ } atfork_lock(); - if (sigchld_owner != ctx) { + if (sigchld_owner != CTX) { struct sigaction ours; assert(!sigchld_owner); - sigchld_owner = ctx; + sigchld_owner = CTX; memset(&ours,0,sizeof(ours)); ours.sa_handler = sigchld_handler; @@ -241,11 +241,11 @@ int libxl__fork_selfpipe_active(libxl_ctx *ctx) return ctx->sigchld_selfpipe[0]; } -static void perhaps_removehandler(libxl_ctx *ctx) +static void perhaps_removehandler(libxl__gc *gc) { - if (LIBXL_LIST_EMPTY(&ctx->children) && - ctx->childproc_hooks->chldowner != libxl_sigchld_owner_libxl_always) - libxl__sigchld_removehandler(ctx); + if (LIBXL_LIST_EMPTY(&CTX->children) && + CTX->childproc_hooks->chldowner != libxl_sigchld_owner_libxl_always) + libxl__sigchld_removehandler(gc); } static int childproc_reaped(libxl__egc *egc, pid_t pid, int status) @@ -265,7 +265,7 @@ static int childproc_reaped(libxl__egc *egc, pid_t pid, int status) ch->pid = -1; ch->callback(egc, ch, pid, status); - perhaps_removehandler(CTX); + perhaps_removehandler(gc); return 0; } @@ -333,7 +333,7 @@ pid_t libxl__ev_child_fork(libxl__gc *gc, libxl__ev_child *ch, int rc; if (chldmode_ours(CTX)) { - rc = libxl__sigchld_installhandler(CTX); + rc = libxl__sigchld_installhandler(gc); if (rc) goto out; } @@ -363,7 +363,7 @@ pid_t libxl__ev_child_fork(libxl__gc *gc, libxl__ev_child *ch, rc = pid; out: - perhaps_removehandler(CTX); + perhaps_removehandler(gc); CTX_UNLOCK; return rc; } @@ -385,10 +385,10 @@ void libxl_childproc_setmode(libxl_ctx *ctx, const libxl_childproc_hooks *hooks, switch (ctx->childproc_hooks->chldowner) { case libxl_sigchld_owner_mainloop: case libxl_sigchld_owner_libxl: - libxl__sigchld_removehandler(ctx); + libxl__sigchld_removehandler(gc); break; case libxl_sigchld_owner_libxl_always: - libxl__sigchld_installhandler(ctx); + libxl__sigchld_installhandler(gc); break; default: abort(); diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 4ad6ad3..d567a10 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -838,8 +838,8 @@ _hidden void libxl__poller_wakeup(libxl__egc *egc, libxl__poller *p); /* Internal to fork and child reaping machinery */ extern const libxl_childproc_hooks libxl__childproc_default_hooks; -int libxl__sigchld_installhandler(libxl_ctx *ctx); /* non-reentrant;logs errs */ -void libxl__sigchld_removehandler(libxl_ctx *ctx); /* non-reentrant */ +int libxl__sigchld_installhandler(libxl__gc*); /* non-reentrant; logs errs */ +void libxl__sigchld_removehandler(libxl__gc*); /* non-reentrant */ int libxl__fork_selfpipe_active(libxl_ctx *ctx); /* returns read fd or -1 */ void libxl__fork_selfpipe_woken(libxl__egc *egc); int libxl__self_pipe_wakeup(int fd); /* returns 0 or -1 setting errno */ -- 1.7.10.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |