From: Ian Jackson <ian.jackson@eu.citrix.com>
To: xen-devel@lists.xen.org
Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>,
Ian Campbell <ian.campbell@citrix.com>
Subject: [PATCH 1/3] libxl: event system: pass gc, not just ctx, to internal sigchld manipulators
Date: Tue, 5 Nov 2013 19:19:11 +0000 [thread overview]
Message-ID: <1383679153-3137-2-git-send-email-ian.jackson@eu.citrix.com> (raw)
In-Reply-To: <1383679153-3137-1-git-send-email-ian.jackson@eu.citrix.com>
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>
---
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 0f0f56c..d0a87d2 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 044ddad..f392d67 100644
--- a/tools/libxl/libxl_fork.c
+++ b/tools/libxl/libxl_fork.c
@@ -173,23 +173,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;
@@ -197,11 +197,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;
@@ -239,11 +239,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)
@@ -263,7 +263,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;
}
@@ -331,7 +331,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;
}
@@ -361,7 +361,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;
}
@@ -383,10 +383,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 4729566..bd2eeed 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
next prev parent reply other threads:[~2013-11-05 19:19 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-05 9:22 [PATCH 0/2] question on libxl ao Bamvor Jian Zhang
2013-11-05 9:22 ` [PATCH 1/2] expose child fd in order to handle child exit in libvirt Bamvor Jian Zhang
2013-11-05 16:05 ` [PATCH 0/2] question on libxl ao [and 1 more messages] Ian Jackson
2013-11-05 19:19 ` [PATCH 0/3] libxl: event system: SIGCHLD related fixes Ian Jackson
2013-11-05 19:19 ` Ian Jackson [this message]
2013-11-06 10:30 ` [PATCH 1/3] libxl: event system: pass gc, not just ctx, to internal sigchld manipulators Ian Campbell
2013-11-05 19:19 ` [PATCH 2/3] libxl: event system: Make libxl_sigchld_owner_libxl_always work Ian Jackson
2013-11-06 10:34 ` Ian Campbell
2013-11-05 19:19 ` [PATCH 3/3] libxl: event system: properly register the SIGCHLD self-pipe Ian Jackson
2013-11-06 10:36 ` Ian Campbell
2013-11-06 10:38 ` [PATCH 0/3] libxl: event system: SIGCHLD related fixes Ian Campbell
2013-11-06 12:08 ` Ian Jackson
2013-11-12 18:27 ` [PATCH v2 " Ian Jackson
2013-11-12 18:27 ` [PATCH 1/3] libxl: event system: pass gc, not just ctx, to internal sigchld manipulators Ian Jackson
2013-11-12 18:27 ` [PATCH 2/3] libxl: event system: Make libxl_sigchld_owner_libxl_always work Ian Jackson
2013-11-12 18:27 ` [PATCH 3/3] libxl: event system: properly register the SIGCHLD self-pipe Ian Jackson
2013-11-13 10:02 ` [PATCH v2 0/3] libxl: event system: SIGCHLD related fixes Ian Campbell
2013-11-21 18:49 ` Ian Jackson
2013-11-20 4:28 ` Jim Fehlig
2013-11-20 15:22 ` 答复: " Bamvor Jian Zhang
2013-11-20 16:40 ` 答复: Re: [PAT CH " Ian Jackson
2013-11-07 3:00 ` [PATCH 0/2] question on libxl ao [and 1 more messages] Bamvor Jian Zhang
2013-11-05 19:23 ` [PATCH 0/2] question on libxl ao [and 1 more messages] " Ian Jackson
2013-11-05 9:22 ` [PATCH 2/2] call ao_how callback explicitly Bamvor Jian Zhang
2013-11-05 15:51 ` Ian Jackson
2013-11-07 14:51 ` Bamvor Jian Zhang
2013-11-07 17:03 ` Ian Jackson
2013-11-08 13:17 ` Bamvor Jian Zhang
2013-11-08 16:07 ` Ian Jackson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1383679153-3137-2-git-send-email-ian.jackson@eu.citrix.com \
--to=ian.jackson@eu.citrix.com \
--cc=ian.campbell@citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).