Skip to content

Commit

Permalink
fix: Actually wait for websocket tasks to complete
Browse files Browse the repository at this point in the history
Otherwise we leak 500mb of tasks per second
  • Loading branch information
qdot committed Jun 25, 2023
1 parent 99a23fd commit a909020
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,7 @@ private async Task RunClientLoop(CancellationToken token)
writeTask,
};

var completedTaskIndex = Task.WhenAny(msgTasks);

var _ = await Task.WhenAny(msgTasks);
if (readTask.IsCompleted)
{
var incomingMsg = await readTask.ConfigureAwait(false);
Expand Down Expand Up @@ -186,6 +185,10 @@ private async Task RunClientLoop(CancellationToken token)
throw new ButtplugClientConnectorException("Websocket Client Read Error", e);
}
}
else if (writeTask.IsCanceled)
{
Console.WriteLine("Write cancelled");
}
}
}
catch (Exception e)
Expand Down

0 comments on commit a909020

Please sign in to comment.