mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
std.Io.Group: fix leak when wait is canceled
Only when the operation succeeds should the token field be set to null.
This commit is contained in:
parent
3de1b6c9a9
commit
c8739d6953
1 changed files with 5 additions and 2 deletions
|
|
@ -1040,11 +1040,14 @@ pub const Group = struct {
|
||||||
|
|
||||||
/// Blocks until all tasks of the group finish.
|
/// Blocks until all tasks of the group finish.
|
||||||
///
|
///
|
||||||
/// Idempotent. Not threadsafe.
|
/// On success, further calls to `wait`, `waitUncancelable`, and `cancel`
|
||||||
|
/// do nothing.
|
||||||
|
///
|
||||||
|
/// Not threadsafe.
|
||||||
pub fn wait(g: *Group, io: Io) Cancelable!void {
|
pub fn wait(g: *Group, io: Io) Cancelable!void {
|
||||||
const token = g.token orelse return;
|
const token = g.token orelse return;
|
||||||
|
try io.vtable.groupWait(io.userdata, g, token);
|
||||||
g.token = null;
|
g.token = null;
|
||||||
return io.vtable.groupWait(io.userdata, g, token);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Equivalent to `wait` except uninterruptible.
|
/// Equivalent to `wait` except uninterruptible.
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue