Skip to content

Commit e6587cd

Browse files
sstabelliniBoris Ostrovsky
authored andcommitted
pvcalls-back: set -ENOTCONN in pvcalls_conn_back_read
When a connection is closing we receive on pvcalls_sk_state_change notification. Instead of setting the connection as closed immediately (-ENOTCONN), let's read one more time from it: pvcalls_conn_back_read will set the connection as closed when necessary. That way, we avoid races between pvcalls_sk_state_change and pvcalls_back_ioworker. 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>
1 parent d90a1ca commit e6587cd

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/xen/pvcalls-back.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,10 @@ static void pvcalls_conn_back_read(void *opaque)
160160

161161
/* write the data, then modify the indexes */
162162
virt_wmb();
163-
if (ret < 0)
163+
if (ret < 0) {
164+
atomic_set(&map->read, 0);
164165
intf->in_error = ret;
165-
else
166+
} else
166167
intf->in_prod = prod + ret;
167168
/* update the indexes, then notify the other end */
168169
virt_wmb();
@@ -288,7 +289,7 @@ static void pvcalls_sk_state_change(struct sock *sock)
288289
return;
289290

290291
intf = map->ring;
291-
intf->in_error = -ENOTCONN;
292+
atomic_inc(&map->read);
292293
notify_remote_via_irq(map->irq);
293294
}
294295

0 commit comments

Comments
 (0)