mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 14:23:09 +00:00
fix race condition in linuxWaitFd
This commit is contained in:
parent
1bd434fd18
commit
cc5e5cca83
@ -440,13 +440,11 @@ pub const Loop = struct {
|
||||
.overlapped = ResumeNode.overlapped_init,
|
||||
},
|
||||
};
|
||||
var need_to_delete = false;
|
||||
var need_to_delete = true;
|
||||
defer if (need_to_delete) self.linuxRemoveFd(fd);
|
||||
|
||||
suspend {
|
||||
if (self.linuxAddFd(fd, &resume_node.base, flags)) |_| {
|
||||
need_to_delete = true;
|
||||
} else |err| switch (err) {
|
||||
self.linuxAddFd(fd, &resume_node.base, flags) catch |err| switch (err) {
|
||||
error.FileDescriptorNotRegistered => unreachable,
|
||||
error.OperationCausesCircularLoop => unreachable,
|
||||
error.FileDescriptorIncompatibleWithEpoll => unreachable,
|
||||
@ -456,6 +454,7 @@ pub const Loop = struct {
|
||||
error.UserResourceLimitReached,
|
||||
error.Unexpected,
|
||||
=> {
|
||||
need_to_delete = false;
|
||||
// Fall back to a blocking poll(). Ideally this codepath is never hit, since
|
||||
// epoll should be just fine. But this is better than incorrect behavior.
|
||||
var poll_flags: i16 = 0;
|
||||
@ -479,7 +478,7 @@ pub const Loop = struct {
|
||||
};
|
||||
resume @frame();
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user