mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
libxl: event: Make LIBXL__EVENT_DISASTER take a gc, not an egc
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
This commit is contained in:
1 parent
9cb0ac86d4
commit
8898caeb95
6 files changed
+25
-25
No files matched your search
@@ -282,7 +282,7 @@ static void datacopier_readable(libxl__egc *egc, libxl__ev_fd *ev,
|
||||
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))
|
||||
|
||||
@@ -33,7 +33,7 @@ static void disk_eject_xswatch_callback(libxl__egc *egc, libxl__ev_xswatch *w,
|
||||
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;
|
||||
}
|
||||
@@ -43,7 +43,7 @@ static void disk_eject_xswatch_callback(libxl__egc *egc, libxl__ev_xswatch *w,
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -892,7 +892,7 @@ static void domain_death_xswatch_callback(libxl__egc *egc, libxl__ev_xswatch *w,
|
||||
|
||||
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;
|
||||
|
||||
+10
-11
@@ -261,7 +261,7 @@ short libxl__fd_poll_recheck(libxl__egc *egc, int fd, short events) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -509,14 +509,14 @@ static void watchfd_callback(libxl__egc *egc, libxl__ev_fd *ev,
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -705,7 +705,7 @@ static int evtchn_revents_check(libxl__egc *egc, int revents)
|
||||
|
||||
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;
|
||||
@@ -746,7 +746,7 @@ static void evtchn_fd_callback(libxl__egc *egc, libxl__ev_fd *ev,
|
||||
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;
|
||||
@@ -966,7 +966,7 @@ static void domaindeathcheck_callback(libxl__egc *egc, libxl__ev_xswatch *w,
|
||||
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;
|
||||
}
|
||||
@@ -1279,7 +1279,7 @@ static void afterpoll_internal(libxl__egc *egc, libxl__poller *poller,
|
||||
|
||||
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 (;;) {
|
||||
@@ -1365,12 +1365,10 @@ void libxl_osevent_occurred_timeout(libxl_ctx *ctx, void *for_libxl)
|
||||
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,
|
||||
@@ -1672,8 +1670,9 @@ void libxl__poller_put(libxl_ctx *ctx, libxl__poller *p)
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -211,6 +211,7 @@ int libxl__carefd_fd(const libxl__carefd *cf)
|
||||
/* 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)
|
||||
@@ -219,7 +220,7 @@ static pid_t checked_waitpid(libxl__egc *egc, pid_t want, int *status)
|
||||
return got;
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
LIBXL__EVENT_DISASTER(egc, "waitpid() failed", errno, 0);
|
||||
LIBXL__EVENT_DISASTER(gc, "waitpid() failed", errno, 0);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -507,7 +508,7 @@ static void childproc_checkall(libxl__egc *egc)
|
||||
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! */
|
||||
@@ -545,14 +546,14 @@ static void sigchld_selfpipe_handler(libxl__egc *egc, libxl__ev_fd *ev,
|
||||
|
||||
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) {
|
||||
@@ -581,7 +582,7 @@ static void sigchld_selfpipe_handler(libxl__egc *egc, libxl__ev_fd *ev,
|
||||
" 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 {
|
||||
|
||||
@@ -1281,8 +1281,8 @@ _hidden libxl_event *libxl__event_new(libxl__egc*, libxl_event_type,
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
@@ -1290,12 +1290,12 @@ _hidden libxl_event *libxl__event_new(libxl__egc*, libxl_event_type,
|
||||
* 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
|
||||
|
||||