pvcalls-front: read all data before closing the connection
authorStefano Stabellini <sstabellini@kernel.org>
Fri, 21 Dec 2018 23:06:29 +0000 (15:06 -0800)
committerBoris Ostrovsky <boris.ostrovsky@oracle.com>
Wed, 2 Jan 2019 15:59:48 +0000 (10:59 -0500)
When a connection is closing in_error is set to ENOTCONN. There could
still be outstanding data on the ring left by the backend. Before
closing the connection on the frontend side, drain the ring.

Signed-off-by: Stefano Stabellini <stefanos@xilinx.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
drivers/xen/pvcalls-front.c

index 77224d8f3e6fe6ee17cb06f81f20be18069422a9..e5d95aab2cb80d5e03e0509326e2e84e32d9c04b 100644 (file)
@@ -560,15 +560,13 @@ static int __read_ring(struct pvcalls_data_intf *intf,
        error = intf->in_error;
        /* get pointers before reading from the ring */
        virt_rmb();
-       if (error < 0)
-               return error;
 
        size = pvcalls_queued(prod, cons, array_size);
        masked_prod = pvcalls_mask(prod, array_size);
        masked_cons = pvcalls_mask(cons, array_size);
 
        if (size == 0)
-               return 0;
+               return error ?: size;
 
        if (len > size)
                len = size;