We are going to want to change libxl__poller_wakeup to take a gc.
In theory there is a risk here that it would be called inappropriately
in a future patch but this seems unlikely.
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Tested-by: George Dunlap <george.dunlap@citrix.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
---
v2: New patch
hupchk.revents = 0;
r = poll(&hupchk, 1, 0);
if (r < 0)
- LIBXL__EVENT_DISASTER(egc,
+ LIBXL__EVENT_DISASTER(gc,
"unexpected failure polling fd for datacopier eof hup check",
errno, 0);
if (datacopier_pollhup_handled(egc, dc, fd, hupchk.revents, 0))
return;
if (libxl__xs_printf(gc, XBT_NULL, wpath, "")) {
- LIBXL__EVENT_DISASTER(egc, "xs_write failed acknowledging eject",
+ LIBXL__EVENT_DISASTER(gc, "xs_write failed acknowledging eject",
errno, LIBXL_EVENT_TYPE_DISK_EJECT);
return;
}
rc = libxl__xs_read_checked(gc, XBT_NULL, evg->be_ptr_path, &backend);
if (rc) {
- LIBXL__EVENT_DISASTER(egc, "xs_read failed reading be_ptr_path",
+ LIBXL__EVENT_DISASTER(gc, "xs_read failed reading be_ptr_path",
errno, LIBXL_EVENT_TYPE_DISK_EJECT);
return;
}
rc = xc_domain_getinfolist(CTX->xch, evg->domid, nentries, domaininfos);
if (rc == -1) {
- LIBXL__EVENT_DISASTER(egc, "xc_domain_getinfolist failed while"
+ LIBXL__EVENT_DISASTER(gc, "xc_domain_getinfolist failed while"
" processing @releaseDomain watch event",
errno, 0);
goto out;
break;
assert(r<0);
if (errno != EINTR) {
- LIBXL__EVENT_DISASTER(egc, "failed poll to check for fd", errno, 0);
+ LIBXL__EVENT_DISASTER(gc, "failed poll to check for fd", errno, 0);
return 0;
}
}
EGC_GC;
if (revents & (POLLERR|POLLHUP))
- LIBXL__EVENT_DISASTER(egc, "unexpected poll event on watch fd", 0, 0);
+ LIBXL__EVENT_DISASTER(gc, "unexpected poll event on watch fd", 0, 0);
for (;;) {
char **event = xs_check_watch(CTX->xsh);
if (!event) {
if (errno == EAGAIN) break;
if (errno == EINTR) continue;
- LIBXL__EVENT_DISASTER(egc, "cannot check/read watches", errno, 0);
+ LIBXL__EVENT_DISASTER(gc, "cannot check/read watches", errno, 0);
return;
}
if (revents & ~POLLIN) {
LOG(ERROR, "unexpected poll event on event channel fd: %x", revents);
- LIBXL__EVENT_DISASTER(egc,
+ LIBXL__EVENT_DISASTER(gc,
"unexpected poll event on event channel fd", 0, 0);
libxl__ev_fd_deregister(gc, &CTX->evtchn_efd);
return ERROR_FAIL;
if (port < 0) {
if (errno == EAGAIN)
break;
- LIBXL__EVENT_DISASTER(egc,
+ LIBXL__EVENT_DISASTER(gc,
"unexpected failure fetching occurring event port number from evtchn",
errno, 0);
return;
libxl__domaindeathcheck_stop(gc,dc);
if (errno!=ENOENT) {
- LIBXL__EVENT_DISASTER(egc,"failed to read xenstore"
+ LIBXL__EVENT_DISASTER(gc,"failed to read xenstore"
" for domain detach check", errno, 0);
return;
}
if (afterpoll_check_fd(poller,fds,nfds, poller->wakeup_pipe[0],POLLIN)) {
int e = libxl__self_pipe_eatall(poller->wakeup_pipe[0]);
- if (e) LIBXL__EVENT_DISASTER(egc, "read wakeup", e, 0);
+ if (e) LIBXL__EVENT_DISASTER(gc, "read wakeup", e, 0);
}
for (;;) {
CTX_UNLOCK_EGC_FREE;
}
-void libxl__event_disaster(libxl__egc *egc, const char *msg, int errnoval,
+void libxl__event_disaster(libxl__gc *gc, const char *msg, int errnoval,
libxl_event_type type /* may be 0 */,
const char *file, int line, const char *func)
{
- EGC_GC;
-
libxl__log(CTX, XTL_CRITICAL, errnoval, file, line, func, INVALID_DOMID,
"DISASTER in event loop: %s%s%s%s",
msg,
void libxl__poller_wakeup(libxl__egc *egc, libxl__poller *p)
{
+ EGC_GC;
int e = libxl__self_pipe_wakeup(p->wakeup_pipe[1]);
- if (e) LIBXL__EVENT_DISASTER(egc, "cannot poke watch pipe", e, 0);
+ if (e) LIBXL__EVENT_DISASTER(gc, "cannot poke watch pipe", e, 0);
}
/*
/* Like waitpid(,,WNOHANG) but handles all errors except ECHILD. */
static pid_t checked_waitpid(libxl__egc *egc, pid_t want, int *status)
{
+ EGC_GC;
for (;;) {
pid_t got = waitpid(want, status, WNOHANG);
if (got != -1)
return got;
if (errno == EINTR)
continue;
- LIBXL__EVENT_DISASTER(egc, "waitpid() failed", errno, 0);
+ LIBXL__EVENT_DISASTER(gc, "waitpid() failed", errno, 0);
return 0;
}
}
found:
if (got == -1) {
LIBXL__EVENT_DISASTER
- (egc, "waitpid() gave ECHILD but we have a child",
+ (gc, "waitpid() gave ECHILD but we have a child",
ECHILD, 0);
/* it must have finished but we don't know its status */
status = 255<<8; /* no wait.h macro for this! */
if (revents & ~POLLIN) {
LOG(ERROR, "unexpected poll event 0x%x on SIGCHLD self pipe", revents);
- LIBXL__EVENT_DISASTER(egc,
+ LIBXL__EVENT_DISASTER(gc,
"unexpected poll event on SIGCHLD self pipe",
0, 0);
}
assert(revents & POLLIN);
int e = libxl__self_pipe_eatall(selfpipe);
- if (e) LIBXL__EVENT_DISASTER(egc, "read sigchld pipe", e, 0);
+ if (e) LIBXL__EVENT_DISASTER(gc, "read sigchld pipe", e, 0);
if (CTX->childproc_hooks->chldowner
== libxl_sigchld_owner_libxl_always_selective_reap) {
" libxl_childproc_hooks->reaped_callback"
" (for pid=%lu, status=%d; error code %d)",
(unsigned long)pid, status, rc);
- LIBXL__EVENT_DISASTER(egc, disasterbuf, 0, 0);
+ LIBXL__EVENT_DISASTER(gc, disasterbuf, 0, 0);
return;
}
} else {
/*
* In general, call this via the macro LIBXL__EVENT_DISASTER.
*
- * Event-generating functions may call this if they might have wanted
- * to generate an event (either an internal one ie a
+ * Event-generating functions, or ao machinery, may call this if they
+ * might have wanted to generate an event (either an internal one ie a
* libxl__ev_FOO_callback or an application event), but are prevented
* from doing so due to eg lack of memory.
*
* then crash, although it may fail (and henceforth leave things in a
* state where many or all calls fail).
*/
-_hidden void libxl__event_disaster(libxl__egc*, const char *msg, int errnoval,
+_hidden void libxl__event_disaster(libxl__gc*, const char *msg, int errnoval,
libxl_event_type type /* may be 0 */,
const char *file, int line,
const char *func);
-#define LIBXL__EVENT_DISASTER(egc, msg, errnoval, type) \
- libxl__event_disaster(egc, msg, errnoval, type, __FILE__,__LINE__,__func__)
+#define LIBXL__EVENT_DISASTER(gc, msg, errnoval, type) \
+ libxl__event_disaster(gc, msg, errnoval, type, __FILE__,__LINE__,__func__)
/* Fills in, or disposes of, the resources held by, a poller whose