win-pvdrivers

changeset 93:2a2f98373c9a

set up WatchEntry before calling xenbus_msg_reply, because we may get a response before msg_reply returns
author Andy Grover <andy.grover@oracle.com>
date Thu Jan 03 16:19:31 2008 -0800 (2008-01-03)
parents 7bcdf94713dc
children ee715addb716
files xenpci/xenbus.c
line diff
     1.1 --- a/xenpci/xenbus.c	Thu Jan 03 16:59:51 2008 +1100
     1.2 +++ b/xenpci/xenbus.c	Thu Jan 03 16:19:31 2008 -0800
     1.3 @@ -611,20 +611,23 @@ XenBus_AddWatch(
     1.4    req[1].data = Token;
     1.5    req[1].len = strlen(Token) + 1;
     1.6  
     1.7 -  rep = xenbus_msg_reply(Device, XS_WATCH, xbt, req, ARRAY_SIZE(req));
     1.8 -
     1.9 -  msg = errmsg(rep);
    1.10 -  if (msg)
    1.11 -    return msg;
    1.12 -
    1.13 -  ExFreePoolWithTag(rep, XENPCI_POOL_TAG);
    1.14 -
    1.15 +  /* must init watchentry before starting watch */
    1.16    strncpy(xpdd->XenBus_WatchEntries[i].Path, Path, 128);
    1.17    xpdd->XenBus_WatchEntries[i].ServiceRoutine = ServiceRoutine;
    1.18    xpdd->XenBus_WatchEntries[i].ServiceContext = ServiceContext;
    1.19    xpdd->XenBus_WatchEntries[i].Count = 0;
    1.20    xpdd->XenBus_WatchEntries[i].Active = 1;
    1.21  
    1.22 +  rep = xenbus_msg_reply(Device, XS_WATCH, xbt, req, ARRAY_SIZE(req));
    1.23 +
    1.24 +  msg = errmsg(rep);
    1.25 +  ExFreePoolWithTag(rep, XENPCI_POOL_TAG);
    1.26 +  if (msg)
    1.27 +  {
    1.28 +    xpdd->XenBus_WatchEntries[i].Active = 0;
    1.29 +    return msg;
    1.30 +  }
    1.31 +
    1.32  //  KdPrint((__DRIVER_NAME " <-- XenBus_AddWatch\n"));
    1.33  
    1.34    return NULL;