From: Keir Fraser Date: Thu, 24 Jul 2008 13:11:47 +0000 (+0100) Subject: mini-os: select call incorrectly reports xce_handle as ready X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~14165^2~133 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=597e548eef7de6cba2f30f47a7f3177e31cadbeb;p=xen.git mini-os: select call incorrectly reports xce_handle as ready The current implementation in minios of xc_evtchn_pending doesn't set read=0 when there is exactly one port pending. This resulted in select() incorrectly reporting the file descriptor as ready. Signed-off-by: Diego Ongaro Signed-off-by: Samuel Thibault --- diff --git a/tools/libxc/xc_minios.c b/tools/libxc/xc_minios.c index 4a5a351aeb..a07b17dd6f 100644 --- a/tools/libxc/xc_minios.c +++ b/tools/libxc/xc_minios.c @@ -292,18 +292,24 @@ evtchn_port_or_error_t xc_evtchn_pending(int xce_handle) { int i; unsigned long flags; + evtchn_port_t ret = -1; + local_irq_save(flags); + files[xce_handle].read = 0; for (i = 0; i < MAX_EVTCHN_PORTS; i++) { - evtchn_port_t port = files[xce_handle].evtchn.ports[i].port; - if (port != -1 && files[xce_handle].evtchn.ports[i].pending) { - files[xce_handle].evtchn.ports[i].pending = 0; - local_irq_restore(flags); - return port; - } + evtchn_port_t port = files[xce_handle].evtchn.ports[i].port; + if (port != -1 && files[xce_handle].evtchn.ports[i].pending) { + if (ret == -1) { + ret = port; + files[xce_handle].evtchn.ports[i].pending = 0; + } else { + files[xce_handle].read = 1; + break; + } + } } - files[xce_handle].read = 0; local_irq_restore(flags); - return -1; + return ret; } int xc_evtchn_unmask(int xce_handle, evtchn_port_t port)