win-pvdrivers

changeset 20:1414d099b564

xenbus: put shorter case first in ReadThreadProc, add some comments
author Andy Grover <andy@groveronline.com>
date Thu Nov 29 16:05:24 2007 -0800 (2007-11-29)
parents 901996235bfc
children e2d29b60b744
files xenpci/xenbus.c
line diff
     1.1 --- a/xenpci/xenbus.c	Thu Nov 29 15:34:01 2007 -0800
     1.2 +++ b/xenpci/xenbus.c	Thu Nov 29 16:05:24 2007 -0800
     1.3 @@ -447,16 +447,22 @@ XenBus_ReadThreadProc(PVOID StartContext
     1.4          break;
     1.5        }
     1.6    
     1.7 -      if(msg.type == XS_WATCH_EVENT)
     1.8 +      if (msg.type != XS_WATCH_EVENT)
     1.9 +      {
    1.10 +        xpdd->req_info[msg.req_id].Reply = ExAllocatePoolWithTag(NonPagedPool, sizeof(msg) + msg.len, XENPCI_POOL_TAG);
    1.11 +        memcpy_from_ring(xpdd->xen_store_interface->rsp,
    1.12 +          xpdd->req_info[msg.req_id].Reply,
    1.13 +          MASK_XENSTORE_IDX(xpdd->xen_store_interface->rsp_cons),
    1.14 +          msg.len + sizeof(msg));
    1.15 +        xpdd->xen_store_interface->rsp_cons += msg.len + sizeof(msg);
    1.16 +        KeSetEvent(&xpdd->req_info[msg.req_id].WaitEvent, 1, FALSE);
    1.17 +      }
    1.18 +      else // a watch: add to watch ring and signal watch thread
    1.19        {
    1.20          payload = ExAllocatePoolWithTag(NonPagedPool, sizeof(msg) + msg.len, XENPCI_POOL_TAG);
    1.21 -  
    1.22          memcpy_from_ring(xpdd->xen_store_interface->rsp, payload,
    1.23            MASK_XENSTORE_IDX(xpdd->xen_store_interface->rsp_cons), msg.len + sizeof(msg));
    1.24 -  
    1.25          xpdd->xen_store_interface->rsp_cons += msg.len + sizeof(msg);
    1.26 -        //KdPrint((__DRIVER_NAME "     b - Rsp_cons %d, rsp_prod %d.\n", xen_store_interface->rsp_cons, xen_store_interface->rsp_prod));
    1.27 -  
    1.28          path = payload + sizeof(msg);
    1.29          token = path + strlen(path) + 1;
    1.30  
    1.31 @@ -478,18 +484,6 @@ XenBus_ReadThreadProc(PVOID StartContext
    1.32          //KdPrint((__DRIVER_NAME " +++ Watch Path = %s Token = %s\n", path, token));
    1.33          KeSetEvent(&xpdd->XenBus_WatchThreadEvent, 1, FALSE);
    1.34        }
    1.35 -      else
    1.36 -      {  
    1.37 -        xpdd->req_info[msg.req_id].Reply = ExAllocatePoolWithTag(NonPagedPool, sizeof(msg) + msg.len, XENPCI_POOL_TAG);
    1.38 -        memcpy_from_ring(xpdd->xen_store_interface->rsp,
    1.39 -          xpdd->req_info[msg.req_id].Reply,
    1.40 -          MASK_XENSTORE_IDX(xpdd->xen_store_interface->rsp_cons),
    1.41 -          msg.len + sizeof(msg));
    1.42 -        xpdd->xen_store_interface->rsp_cons += msg.len + sizeof(msg);
    1.43 -        //KdPrint((__DRIVER_NAME "     c - Rsp_cons %d, rsp_prod %d.\n", xen_store_interface->rsp_cons, xen_store_interface->rsp_prod));
    1.44 -        //KdPrint((__DRIVER_NAME " +++ Message = %s\n", ((char *)req_info[msg.req_id].Reply) + sizeof(msg)));
    1.45 -        KeSetEvent(&xpdd->req_info[msg.req_id].WaitEvent, 1, FALSE);
    1.46 -      }
    1.47      }
    1.48    }
    1.49  }