ia64/xen-unstable

changeset 6821:1ad652222dba

Perform xenbus operations in shutdown_handler in a transaction.
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Tue Sep 13 21:29:28 2005 +0000 (2005-09-13)
parents 36c4d3bb29c8
children 0d8c0db04258
files linux-2.6-xen-sparse/arch/xen/kernel/reboot.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c	Tue Sep 13 21:24:03 2005 +0000
     1.2 +++ b/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c	Tue Sep 13 21:29:28 2005 +0000
     1.3 @@ -320,20 +320,28 @@ static void __shutdown_handler(void *unu
     1.4  static void shutdown_handler(struct xenbus_watch *watch, const char *node)
     1.5  {
     1.6      static DECLARE_WORK(shutdown_work, __shutdown_handler, NULL);
     1.7 +    char *str;
     1.8 +    int err;
     1.9  
    1.10 -    char *str;
    1.11 -
    1.12 + again:
    1.13 +    err = xenbus_transaction_start("control");
    1.14 +    if (err)
    1.15 +	return;
    1.16      str = (char *)xenbus_read("control", "shutdown", NULL);
    1.17 -    /* Ignore read errors. */
    1.18 -    if (IS_ERR(str))
    1.19 -        return;
    1.20 -    if (strlen(str) == 0) {
    1.21 -        kfree(str);
    1.22 -        return;
    1.23 +    /* Ignore read errors and empty reads. */
    1.24 +    if (XENBUS_IS_ERR_READ(str)) {
    1.25 +	xenbus_transaction_end(1);
    1.26 +	return;
    1.27      }
    1.28  
    1.29      xenbus_write("control", "shutdown", "", O_CREAT);
    1.30  
    1.31 +    err = xenbus_transaction_end(0);
    1.32 +    if (err == -ETIMEDOUT) {
    1.33 +	kfree(str);
    1.34 +	goto again;
    1.35 +    }
    1.36 +
    1.37      if (strcmp(str, "poweroff") == 0)
    1.38          shutting_down = SHUTDOWN_POWEROFF;
    1.39      else if (strcmp(str, "reboot") == 0)