aboutsummaryrefslogtreecommitdiffstats
path: root/tools/console/daemon
diff options
context:
space:
mode:
authorKeir Fraser <keir@xensource.com>2007-06-27 21:05:54 +0100
committerKeir Fraser <keir@xensource.com>2007-06-27 21:05:54 +0100
commit3f96f21796c6ab5ffec50b70e0457d973eb5d9c2 (patch)
tree2374dc92ec6fbf4eb2a94ceaa780eec9f4b47906 /tools/console/daemon
parent3bc33badf2f2afcb61dca3ee5446e4c13f0c26b4 (diff)
downloadxen-3f96f21796c6ab5ffec50b70e0457d973eb5d9c2.tar.gz
xen-3f96f21796c6ab5ffec50b70e0457d973eb5d9c2.tar.bz2
xen-3f96f21796c6ab5ffec50b70e0457d973eb5d9c2.zip
xenconsoled: improve robustness of logfile handling
Check the 'log_reload' on every iteration of the select() loop, not just when select() returns EINTR. This is because the log reload signal may have iterrupted a syscall other than select & thus without this change we might miss the reload signal. The second change makes us process the hypervisor logs on every iteration of the loop, not just upon timeouts. This is because if a guest VM were consistently sending some log message and < 1 second period, the select() would never hit the 1 second timeout and thus never process the HV logs. Thanks to Markus Armbruster for pointing out both these edge cases Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Diffstat (limited to 'tools/console/daemon')
-rw-r--r--tools/console/daemon/io.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
index d67f4c3abd..42015ebc29 100644
--- a/tools/console/daemon/io.c
+++ b/tools/console/daemon/io.c
@@ -764,27 +764,31 @@ void handle_io(void)
/* XXX I wish we didn't have to busy wait for hypervisor logs
* but there's no obvious way to get event channel notifications
* for new HV log data as we can with guest */
- ret = select(max_fd + 1, &readfds, &writefds, 0, log_hv_fd != -1 ? &timeout : NULL);
+ ret = select(max_fd + 1, &readfds, &writefds, 0,
+ log_hv_fd != -1 ? &timeout : NULL);
+ if (log_reload) {
+ handle_log_reload();
+ log_reload = 0;
+ }
+
+ /* Abort if select failed, except for EINTR cases
+ which indicate a possible log reload */
if (ret == -1) {
- if (errno == EINTR) {
- if (log_reload) {
- handle_log_reload();
- log_reload = 0;
- }
+ if (errno == EINTR)
continue;
- }
dolog(LOG_ERR, "Failure in select: %d (%s)",
errno, strerror(errno));
break;
}
- /* Check for timeout */
- if (ret == 0) {
- if (log_hv_fd != -1)
- handle_hv_logs();
+ /* Always process HV logs even if not a timeout */
+ if (log_hv_fd != -1)
+ handle_hv_logs();
+
+ /* Must not check returned FDSET if it was a timeout */
+ if (ret == 0)
continue;
- }
if (FD_ISSET(xs_fileno(xs), &readfds))
handle_xs();
@@ -806,10 +810,14 @@ void handle_io(void)
}
}
- if (log_hv_fd != -1)
+ if (log_hv_fd != -1) {
close(log_hv_fd);
- if (xc_handle != -1)
+ log_hv_fd = -1;
+ }
+ if (xc_handle != -1) {
xc_interface_close(xc_handle);
+ xc_handle = -1;
+ }
}
/*