]> xenbits.xensource.com Git - people/vhanquez/xen.git/commitdiff
Read the message type out of the message before sending it to xenstored, and
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Sat, 15 Apr 2006 21:48:08 +0000 (22:48 +0100)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Sat, 15 Apr 2006 21:48:08 +0000 (22:48 +0100)
use that saved value when handling the reply.  Xenstored will leave the
message type intact, _except_ when returning an error, in which case it will
change the type to XS_ERROR.  This meant that we failed to remove a
transaction from our internal list if xenstored returned EAGAIN, as we did not
realise that the message was XS_TRANSACTION_END.  This manifested itself as
the intended behaviour until the connection was closed, at which point all of
those failed transactions would erroneously be aborted.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c

index 282cdafb98156e0e0e1d5549d60694baf2a7451a..cb00af2dababb615e62d4d399ad56914e4e6e959 100644 (file)
@@ -114,6 +114,7 @@ static ssize_t xenbus_dev_write(struct file *filp,
 {
        struct xenbus_dev_data *u = filp->private_data;
        struct xenbus_dev_transaction *trans = NULL;
+       uint32_t msg_type;
        void *reply;
 
        if ((len + u->len) > sizeof(u->u.buffer))
@@ -126,7 +127,9 @@ static ssize_t xenbus_dev_write(struct file *filp,
        if (u->len < (sizeof(u->u.msg) + u->u.msg.len))
                return len;
 
-       switch (u->u.msg.type) {
+       msg_type = u->u.msg.type;
+
+       switch (msg_type) {
        case XS_TRANSACTION_START:
        case XS_TRANSACTION_END:
        case XS_DIRECTORY:
@@ -138,7 +141,7 @@ static ssize_t xenbus_dev_write(struct file *filp,
        case XS_MKDIR:
        case XS_RM:
        case XS_SET_PERMS:
-               if (u->u.msg.type == XS_TRANSACTION_START) {
+               if (msg_type == XS_TRANSACTION_START) {
                        trans = kmalloc(sizeof(*trans), GFP_KERNEL);
                        if (!trans)
                                return -ENOMEM;
@@ -150,10 +153,10 @@ static ssize_t xenbus_dev_write(struct file *filp,
                        return PTR_ERR(reply);
                }
 
-               if (u->u.msg.type == XS_TRANSACTION_START) {
+               if (msg_type == XS_TRANSACTION_START) {
                        trans->handle = simple_strtoul(reply, NULL, 0);
                        list_add(&trans->list, &u->transactions);
-               } else if (u->u.msg.type == XS_TRANSACTION_END) {
+               } else if (msg_type == XS_TRANSACTION_END) {
                        list_for_each_entry(trans, &u->transactions, list)
                                if (trans->handle == u->u.msg.tx_id)
                                        break;