Skip to content

Commit

Permalink
hv_vmbus: vmbus_hvsock_device_unregister() should finish ASAP
Browse files Browse the repository at this point in the history
Without the patch, the application's close() hangs here, before the host
closes the connection.

TAG_MSFT: lcow
TAG_MSFT: wsl

Signed-off-by: Dexuan Cui <decui@microsoft.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
  • Loading branch information
dcui authored and Sasha Levin committed Jun 26, 2019
1 parent 440c4ff commit 50a0f1b
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions drivers/hv/channel_mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1022,9 +1022,24 @@ void vmbus_hvsock_device_unregister(struct vmbus_channel *channel)
{
BUG_ON(!is_hvsock_channel(channel));

/* We always get a rescind msg when a connection is closed. */
while (!READ_ONCE(channel->probe_done) || !READ_ONCE(channel->rescind))
for (;;) {
if (!READ_ONCE(channel->probe_done)) {
msleep(1);
continue;
}

/* We always get a rescind msg when a connection is closed. */
if (READ_ONCE(channel->rescind))
break;

if (hv_get_bytes_to_read(&channel->outbound) == 0)
break;

msleep(1);
}

/* FIXME: in case vmbus_onoffer_rescin() runs too slow */
channel->rescind = true;

vmbus_device_unregister(channel->device_obj);
}
Expand Down

0 comments on commit 50a0f1b

Please sign in to comment.