[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] libxl: make libxl_wait_for_device_model clearer
# HG changeset patch # User Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx> # Date 1277309066 -3600 # Node ID f3d3fb7da2c976ae996abf681626b8ca5a0e9eff # Parent c973b5b8d17edf4d60057886fb47192a16175608 libxl: make libxl_wait_for_device_model clearer at the moment libxl_wait_for_device_model waits on a xenstore watch before checking the current value of the xenstore node, that might contain already the value the function was looking for. This patch changes libxl_wait_for_device_model so that it checks the value of the xenstore node first, then waits for the watch. xenstore watch automatically fire one time when you install them for this exact same purpose, so the previous code is not wrong, but this version is clearer. Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx> --- tools/libxl/libxl_device.c | 39 ++++++++++++++++++++------------------- 1 files changed, 20 insertions(+), 19 deletions(-) diff -r c973b5b8d17e -r f3d3fb7da2c9 tools/libxl/libxl_device.c --- a/tools/libxl/libxl_device.c Wed Jun 23 17:01:35 2010 +0100 +++ b/tools/libxl/libxl_device.c Wed Jun 23 17:04:26 2010 +0100 @@ -418,7 +418,7 @@ int libxl_wait_for_device_model(struct l char *path; char *p; unsigned int len; - int rc; + int rc = 0; struct xs_handle *xsh; int nfds; fd_set rfds; @@ -432,28 +432,29 @@ int libxl_wait_for_device_model(struct l tv.tv_sec = LIBXL_DEVICE_MODEL_START_TIMEOUT; tv.tv_usec = 0; nfds = xs_fileno(xsh) + 1; - while (tv.tv_sec > 0) { + while (rc > 0 || (!rc && tv.tv_sec > 0)) { + p = xs_read(xsh, XBT_NULL, path, &len); + if (p && (!state || !strcmp(state, p))) { + free(p); + xs_unwatch(xsh, path, path); + xs_daemon_close(xsh); + if (check_callback) { + rc = check_callback(ctx, check_callback_userdata); + if (rc) return rc; + } + return 0; + } + free(p); +again: FD_ZERO(&rfds); FD_SET(xs_fileno(xsh), &rfds); - if (select(nfds, &rfds, NULL, NULL, &tv) > 0) { + rc = select(nfds, &rfds, NULL, NULL, &tv); + if (rc > 0) { l = xs_read_watch(xsh, &num); - if (l != NULL) { + if (l != NULL) free(l); - p = xs_read(xsh, XBT_NULL, path, &len); - if (!p) - continue; - if (!state || !strcmp(state, p)) { - free(p); - xs_unwatch(xsh, path, path); - xs_daemon_close(xsh); - if (check_callback) { - rc = check_callback(ctx, check_callback_userdata); - if (rc) return rc; - } - return 0; - } - free(p); - } + else + goto again; } } xs_unwatch(xsh, path, path); _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |