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@eu.citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
This commit is contained in:
Ian Jackson authored and Ian Jackson committed 2013-11-21 18:47:24 +00:00
1 parent f400f2993b
commit 5d2f96adc8
3 files changed
+21 -21

No files matched your search

+1 -1
View File
@@ -164,7 +164,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]);
+18 -18
View File
@@ -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();
+2 -2
View File
@@ -837,8 +837,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 */
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.