fence-virt: Fix for missed libvirtd events
Fix a bug that caused some libvirtd events to be missed. This bug could cause client requests to fail in cases where VMs were either started or live migrated to a node after fence_virtd had already started. Resolves: rhbz#903172 Signed-off-by: Ryan McCabe <rmccabe@redhat.com>
This commit is contained in:
parent
04710b4079
commit
61ab01bb5c
@ -275,7 +275,9 @@ serial_dispatch(listener_context_t c, struct timeval *timeout)
|
||||
|
||||
n = select(max+1, &rfds, NULL, NULL, timeout);
|
||||
if (n < 0) {
|
||||
perror("select");
|
||||
if (errno == ETIMEDOUT || errno == EINTR || errno == EAGAIN)
|
||||
return 0;
|
||||
dbg_printf(2, "select: %s\n", strerror(errno));
|
||||
return n;
|
||||
}
|
||||
|
||||
@ -306,7 +308,7 @@ serial_dispatch(listener_context_t c, struct timeval *timeout)
|
||||
ret = _read_retry(x, &data, sizeof(data), &tv);
|
||||
|
||||
if (ret != sizeof(data)) {
|
||||
if (--n)
|
||||
if (--n > 0)
|
||||
continue;
|
||||
else
|
||||
return 0;
|
||||
|
@ -432,8 +432,9 @@ event_thread(void *arg)
|
||||
dbg_printf(3," * URI: %s\n", args->uri);
|
||||
if (args->path)
|
||||
dbg_printf(3," * Socket path: %s\n", args->path);
|
||||
dbg_printf(3," * Mode: %s\n", args->mode?"VMChannel":"Serial");
|
||||
dbg_printf(3," * Mode: %s\n", args->mode ? "VMChannel" : "Serial");
|
||||
|
||||
top:
|
||||
virEventRegisterImpl(myEventAddHandleFunc,
|
||||
myEventUpdateHandleFunc,
|
||||
myEventRemoveHandleFunc,
|
||||
@ -451,14 +452,13 @@ event_thread(void *arg)
|
||||
|
||||
registerExisting(dconn, args->path, args->mode);
|
||||
|
||||
/* Add 2 callbacks to prove this works with more than just one */
|
||||
callback1ret =
|
||||
virConnectDomainEventRegister(dconn, myDomainEventCallback1,
|
||||
arg, NULL);
|
||||
virConnectDomainEventRegister(dconn, myDomainEventCallback1, arg, NULL);
|
||||
|
||||
if ((callback1ret == 0)) {
|
||||
if (callback1ret == 0) {
|
||||
while (run) {
|
||||
struct pollfd pfd = {.fd = h_fd,
|
||||
struct pollfd pfd = {
|
||||
.fd = h_fd,
|
||||
.events = h_event,
|
||||
.revents = 0
|
||||
};
|
||||
@ -481,13 +481,16 @@ event_thread(void *arg)
|
||||
|
||||
if (pfd.revents & POLLHUP) {
|
||||
DEBUG0("Reset by peer");
|
||||
goto out;
|
||||
virConnectDomainEventDeregister(dconn, myDomainEventCallback1);
|
||||
if (dconn && virConnectClose(dconn) < 0)
|
||||
dbg_printf(1, "error closing libvirt connection\n");
|
||||
DEBUG0("Attempting to reinitialize libvirt connection");
|
||||
goto top;
|
||||
}
|
||||
|
||||
if (h_cb) {
|
||||
h_cb(0, h_fd,
|
||||
myPollEventToEventHandleType(pfd.revents &
|
||||
h_event),
|
||||
myPollEventToEventHandleType(pfd.revents & h_event),
|
||||
h_opaque);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user