ia64/xen-unstable

changeset 18148:16ba99f816a3

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 <diego.ongaro@citrix.com>
Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jul 24 14:11:47 2008 +0100 (2008-07-24)
parents 6604234057f6
children 707569df20e1
files tools/libxc/xc_minios.c
line diff
     1.1 --- a/tools/libxc/xc_minios.c	Thu Jul 24 14:10:45 2008 +0100
     1.2 +++ b/tools/libxc/xc_minios.c	Thu Jul 24 14:11:47 2008 +0100
     1.3 @@ -292,18 +292,24 @@ evtchn_port_or_error_t xc_evtchn_pending
     1.4  {
     1.5      int i;
     1.6      unsigned long flags;
     1.7 +    evtchn_port_t ret = -1;
     1.8 +
     1.9      local_irq_save(flags);
    1.10 +    files[xce_handle].read = 0;
    1.11      for (i = 0; i < MAX_EVTCHN_PORTS; i++) {
    1.12 -	evtchn_port_t port = files[xce_handle].evtchn.ports[i].port;
    1.13 -	if (port != -1 && files[xce_handle].evtchn.ports[i].pending) {
    1.14 -	    files[xce_handle].evtchn.ports[i].pending = 0;
    1.15 -	    local_irq_restore(flags);
    1.16 -	    return port;
    1.17 -	}
    1.18 +        evtchn_port_t port = files[xce_handle].evtchn.ports[i].port;
    1.19 +        if (port != -1 && files[xce_handle].evtchn.ports[i].pending) {
    1.20 +            if (ret == -1) {
    1.21 +                ret = port;
    1.22 +                files[xce_handle].evtchn.ports[i].pending = 0;
    1.23 +            } else {
    1.24 +                files[xce_handle].read = 1;
    1.25 +                break;
    1.26 +            }
    1.27 +        }
    1.28      }
    1.29 -    files[xce_handle].read = 0;
    1.30      local_irq_restore(flags);
    1.31 -    return -1;
    1.32 +    return ret;
    1.33  }
    1.34  
    1.35  int xc_evtchn_unmask(int xce_handle, evtchn_port_t port)