mirror of
https://github.com/ziglang/zig.git
synced 2026-02-14 13:30:45 +00:00
Merge pull request #6399 from FireFox317/async-fix
Eventloop: Fix deadlock in linux event loop implementation
This commit is contained in:
commit
0f3111379b
@ -687,9 +687,14 @@ pub const Loop = struct {
|
||||
|
||||
switch (builtin.os.tag) {
|
||||
.linux => {
|
||||
// writing 8 bytes to an eventfd cannot fail
|
||||
const amt = os.write(self.os_data.final_eventfd, &wakeup_bytes) catch unreachable;
|
||||
assert(amt == wakeup_bytes.len);
|
||||
// writing to the eventfd will only wake up one thread, thus multiple writes
|
||||
// are needed to wakeup all the threads
|
||||
var i: usize = 0;
|
||||
while (i < self.extra_threads.len + 1) : (i += 1) {
|
||||
// writing 8 bytes to an eventfd cannot fail
|
||||
const amt = os.write(self.os_data.final_eventfd, &wakeup_bytes) catch unreachable;
|
||||
assert(amt == wakeup_bytes.len);
|
||||
}
|
||||
return;
|
||||
},
|
||||
.macosx, .freebsd, .netbsd, .dragonfly => {
|
||||
@ -1252,11 +1257,6 @@ test "std.event.Loop - basic" {
|
||||
// https://github.com/ziglang/zig/issues/1908
|
||||
if (builtin.single_threaded) return error.SkipZigTest;
|
||||
|
||||
if (true) {
|
||||
// https://github.com/ziglang/zig/issues/4922
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
var loop: Loop = undefined;
|
||||
try loop.initMultiThreaded();
|
||||
defer loop.deinit();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user