| author | |
| committer | |
| log | 3f34f5e43349214c862882a83bd951701a6c735f |
| tree | 031d1ab910775458fb6066f5379b54e2e44e1baf |
| parent | a242292644a12b8ca0485759ba45c550265da5bd |
6 files changed, 149 insertions(+), 112 deletions(-)
lib/compiler/build_runner.zig+9-9| ... | ... | @@ -494,7 +494,7 @@ pub fn main() !void { |
| 494 | 494 | |
| 495 | 495 | .max_rss = max_rss, |
| 496 | 496 | .max_rss_is_default = false, |
| 497 | .max_rss_mutex = .{}, | |
| 497 | .max_rss_mutex = .init, | |
| 498 | 498 | .skip_oom_steps = skip_oom_steps, |
| 499 | 499 | .unit_test_timeout_ns = test_timeout_ns, |
| 500 | 500 | |
| ... | ... | @@ -583,7 +583,7 @@ pub fn main() !void { |
| 583 | 583 | |
| 584 | 584 | if (run.web_server) |*ws| { |
| 585 | 585 | assert(!watch); // fatal error after CLI parsing |
| 586 | while (true) switch (ws.wait()) { | |
| 586 | while (true) switch (try ws.wait()) { | |
| 587 | 587 | .rebuild => { |
| 588 | 588 | for (run.step_stack.keys()) |step| { |
| 589 | 589 | step.state = .precheck_done; |
| ... | ... | @@ -652,7 +652,7 @@ const Run = struct { |
| 652 | 652 | gpa: Allocator, |
| 653 | 653 | max_rss: u64, |
| 654 | 654 | max_rss_is_default: bool, |
| 655 | max_rss_mutex: std.Thread.Mutex, | |
| 655 | max_rss_mutex: Io.Mutex, | |
| 656 | 656 | skip_oom_steps: bool, |
| 657 | 657 | unit_test_timeout_ns: ?u64, |
| 658 | 658 | watch: bool, |
| ... | ... | @@ -1305,6 +1305,8 @@ fn workerMakeOneStep( |
| 1305 | 1305 | prog_node: std.Progress.Node, |
| 1306 | 1306 | run: *Run, |
| 1307 | 1307 | ) void { |
| 1308 | const io = b.graph.io; | |
| 1309 | ||
| 1308 | 1310 | // First, check the conditions for running this step. If they are not met, |
| 1309 | 1311 | // then we return without doing the step, relying on another worker to |
| 1310 | 1312 | // queue this step up again when dependencies are met. |
| ... | ... | @@ -1326,8 +1328,8 @@ fn workerMakeOneStep( |
| 1326 | 1328 | } |
| 1327 | 1329 | |
| 1328 | 1330 | if (s.max_rss != 0) { |
| 1329 | run.max_rss_mutex.lock(); | |
| 1330 | defer run.max_rss_mutex.unlock(); | |
| 1331 | run.max_rss_mutex.lockUncancelable(io); | |
| 1332 | defer run.max_rss_mutex.unlock(io); | |
| 1331 | 1333 | |
| 1332 | 1334 | // Avoid running steps twice. |
| 1333 | 1335 | if (s.state != .precheck_done) { |
| ... | ... | @@ -1378,8 +1380,6 @@ fn workerMakeOneStep( |
| 1378 | 1380 | printErrorMessages(run.gpa, s, .{}, bw, ttyconf, run.error_style, run.multiline_errors) catch {}; |
| 1379 | 1381 | } |
| 1380 | 1382 | |
| 1381 | const io = b.graph.io; | |
| 1382 | ||
| 1383 | 1383 | handle_result: { |
| 1384 | 1384 | if (make_result) |_| { |
| 1385 | 1385 | @atomicStore(Step.State, &s.state, .success, .seq_cst); |
| ... | ... | @@ -1406,8 +1406,8 @@ fn workerMakeOneStep( |
| 1406 | 1406 | // If this is a step that claims resources, we must now queue up other |
| 1407 | 1407 | // steps that are waiting for resources. |
| 1408 | 1408 | if (s.max_rss != 0) { |
| 1409 | run.max_rss_mutex.lock(); | |
| 1410 | defer run.max_rss_mutex.unlock(); | |
| 1409 | run.max_rss_mutex.lockUncancelable(io); | |
| 1410 | defer run.max_rss_mutex.unlock(io); | |
| 1411 | 1411 | |
| 1412 | 1412 | // Give the memory back to the scheduler. |
| 1413 | 1413 | run.claimed_rss -= s.max_rss; |
lib/std/Build/Cache.zig+22-9| ... | ... | @@ -22,7 +22,7 @@ manifest_dir: fs.Dir, |
| 22 | 22 | hash: HashHelper = .{}, |
| 23 | 23 | /// This value is accessed from multiple threads, protected by mutex. |
| 24 | 24 | recent_problematic_timestamp: Io.Timestamp = .zero, |
| 25 | mutex: std.Thread.Mutex = .{}, | |
| 25 | mutex: Io.Mutex = .init, | |
| 26 | 26 | |
| 27 | 27 | /// A set of strings such as the zig library directory or project source root, which |
| 28 | 28 | /// are stripped from the file paths before putting into the cache. They |
| ... | ... | @@ -474,6 +474,7 @@ pub const Manifest = struct { |
| 474 | 474 | /// A cache manifest file exists however it could not be parsed. |
| 475 | 475 | InvalidFormat, |
| 476 | 476 | OutOfMemory, |
| 477 | Canceled, | |
| 477 | 478 | }; |
| 478 | 479 | |
| 479 | 480 | /// Check the cache to see if the input exists in it. If it exists, returns `true`. |
| ... | ... | @@ -559,12 +560,14 @@ pub const Manifest = struct { |
| 559 | 560 | self.diagnostic = .{ .manifest_create = error.FileNotFound }; |
| 560 | 561 | return error.CacheCheckFailed; |
| 561 | 562 | }, |
| 563 | error.Canceled => return error.Canceled, | |
| 562 | 564 | else => |e| { |
| 563 | 565 | self.diagnostic = .{ .manifest_create = e }; |
| 564 | 566 | return error.CacheCheckFailed; |
| 565 | 567 | }, |
| 566 | 568 | } |
| 567 | 569 | }, |
| 570 | error.Canceled => return error.Canceled, | |
| 568 | 571 | else => |e| { |
| 569 | 572 | self.diagnostic = .{ .manifest_create = e }; |
| 570 | 573 | return error.CacheCheckFailed; |
| ... | ... | @@ -762,6 +765,7 @@ pub const Manifest = struct { |
| 762 | 765 | // Every digest before this one has been populated successfully. |
| 763 | 766 | return .{ .miss = .{ .file_digests_populated = idx } }; |
| 764 | 767 | }, |
| 768 | error.Canceled => return error.Canceled, | |
| 765 | 769 | else => |e| { |
| 766 | 770 | self.diagnostic = .{ .file_open = .{ |
| 767 | 771 | .file_index = idx, |
| ... | ... | @@ -790,7 +794,7 @@ pub const Manifest = struct { |
| 790 | 794 | .inode = actual_stat.inode, |
| 791 | 795 | }; |
| 792 | 796 | |
| 793 | if (self.isProblematicTimestamp(cache_hash_file.stat.mtime)) { | |
| 797 | if (try self.isProblematicTimestamp(cache_hash_file.stat.mtime)) { | |
| 794 | 798 | // The actual file has an unreliable timestamp, force it to be hashed |
| 795 | 799 | cache_hash_file.stat.mtime = .zero; |
| 796 | 800 | cache_hash_file.stat.inode = 0; |
| ... | ... | @@ -848,7 +852,9 @@ pub const Manifest = struct { |
| 848 | 852 | } |
| 849 | 853 | } |
| 850 | 854 | |
| 851 | fn isProblematicTimestamp(man: *Manifest, timestamp: Io.Timestamp) bool { | |
| 855 | fn isProblematicTimestamp(man: *Manifest, timestamp: Io.Timestamp) error{Canceled}!bool { | |
| 856 | const io = man.cache.io; | |
| 857 | ||
| 852 | 858 | // If the file_time is prior to the most recent problematic timestamp |
| 853 | 859 | // then we don't need to access the filesystem. |
| 854 | 860 | if (timestamp.nanoseconds < man.recent_problematic_timestamp.nanoseconds) |
| ... | ... | @@ -856,8 +862,8 @@ pub const Manifest = struct { |
| 856 | 862 | |
| 857 | 863 | // Next we will check the globally shared Cache timestamp, which is accessed |
| 858 | 864 | // from multiple threads. |
| 859 | man.cache.mutex.lock(); | |
| 860 | defer man.cache.mutex.unlock(); | |
| 865 | try man.cache.mutex.lock(io); | |
| 866 | defer man.cache.mutex.unlock(io); | |
| 861 | 867 | |
| 862 | 868 | // Save the global one to our local one to avoid locking next time. |
| 863 | 869 | man.recent_problematic_timestamp = man.cache.recent_problematic_timestamp; |
| ... | ... | @@ -871,11 +877,18 @@ pub const Manifest = struct { |
| 871 | 877 | var file = man.cache.manifest_dir.createFile("timestamp", .{ |
| 872 | 878 | .read = true, |
| 873 | 879 | .truncate = true, |
| 874 | }) catch return true; | |
| 880 | }) catch |err| switch (err) { | |
| 881 | error.Canceled => return error.Canceled, | |
| 882 | else => return true, | |
| 883 | }; | |
| 875 | 884 | defer file.close(); |
| 876 | 885 | |
| 877 | 886 | // Save locally and also save globally (we still hold the global lock). |
| 878 | man.recent_problematic_timestamp = (file.stat() catch return true).mtime; | |
| 887 | const stat = file.stat() catch |err| switch (err) { | |
| 888 | error.Canceled => return error.Canceled, | |
| 889 | else => return true, | |
| 890 | }; | |
| 891 | man.recent_problematic_timestamp = stat.mtime; | |
| 879 | 892 | man.cache.recent_problematic_timestamp = man.recent_problematic_timestamp; |
| 880 | 893 | } |
| 881 | 894 | |
| ... | ... | @@ -902,7 +915,7 @@ pub const Manifest = struct { |
| 902 | 915 | .inode = actual_stat.inode, |
| 903 | 916 | }; |
| 904 | 917 | |
| 905 | if (self.isProblematicTimestamp(ch_file.stat.mtime)) { | |
| 918 | if (try self.isProblematicTimestamp(ch_file.stat.mtime)) { | |
| 906 | 919 | // The actual file has an unreliable timestamp, force it to be hashed |
| 907 | 920 | ch_file.stat.mtime = .zero; |
| 908 | 921 | ch_file.stat.inode = 0; |
| ... | ... | @@ -1038,7 +1051,7 @@ pub const Manifest = struct { |
| 1038 | 1051 | .contents = null, |
| 1039 | 1052 | }; |
| 1040 | 1053 | |
| 1041 | if (self.isProblematicTimestamp(new_file.stat.mtime)) { | |
| 1054 | if (try self.isProblematicTimestamp(new_file.stat.mtime)) { | |
| 1042 | 1055 | // The actual file has an unreliable timestamp, force it to be hashed |
| 1043 | 1056 | new_file.stat.mtime = .zero; |
| 1044 | 1057 | new_file.stat.inode = 0; |
lib/std/Build/Fuzz.zig+48-37| ... | ... | @@ -27,11 +27,11 @@ root_prog_node: std.Progress.Node, |
| 27 | 27 | prog_node: std.Progress.Node, |
| 28 | 28 | |
| 29 | 29 | /// Protects `coverage_files`. |
| 30 | coverage_mutex: std.Thread.Mutex, | |
| 30 | coverage_mutex: Io.Mutex, | |
| 31 | 31 | coverage_files: std.AutoArrayHashMapUnmanaged(u64, CoverageMap), |
| 32 | 32 | |
| 33 | queue_mutex: std.Thread.Mutex, | |
| 34 | queue_cond: std.Thread.Condition, | |
| 33 | queue_mutex: Io.Mutex, | |
| 34 | queue_cond: Io.Condition, | |
| 35 | 35 | msg_queue: std.ArrayList(Msg), |
| 36 | 36 | |
| 37 | 37 | pub const Mode = union(enum) { |
| ... | ... | @@ -122,8 +122,8 @@ pub fn init( |
| 122 | 122 | .root_prog_node = root_prog_node, |
| 123 | 123 | .prog_node = .none, |
| 124 | 124 | .coverage_files = .empty, |
| 125 | .coverage_mutex = .{}, | |
| 126 | .queue_mutex = .{}, | |
| 125 | .coverage_mutex = .init, | |
| 126 | .queue_mutex = .init, | |
| 127 | 127 | .queue_cond = .{}, |
| 128 | 128 | .msg_queue = .empty, |
| 129 | 129 | }; |
| ... | ... | @@ -157,9 +157,7 @@ pub fn deinit(fuzz: *Fuzz) void { |
| 157 | 157 | fn rebuildTestsWorkerRun(run: *Step.Run, gpa: Allocator, ttyconf: tty.Config, parent_prog_node: std.Progress.Node) void { |
| 158 | 158 | rebuildTestsWorkerRunFallible(run, gpa, ttyconf, parent_prog_node) catch |err| { |
| 159 | 159 | const compile = run.producer.?; |
| 160 | log.err("step '{s}': failed to rebuild in fuzz mode: {s}", .{ | |
| 161 | compile.step.name, @errorName(err), | |
| 162 | }); | |
| 160 | log.err("step '{s}': failed to rebuild in fuzz mode: {t}", .{ compile.step.name, err }); | |
| 163 | 161 | }; |
| 164 | 162 | } |
| 165 | 163 | |
| ... | ... | @@ -208,9 +206,7 @@ fn fuzzWorkerRun( |
| 208 | 206 | return; |
| 209 | 207 | }, |
| 210 | 208 | else => { |
| 211 | log.err("step '{s}': failed to rerun '{s}' in fuzz mode: {s}", .{ | |
| 212 | run.step.name, test_name, @errorName(err), | |
| 213 | }); | |
| 209 | log.err("step '{s}': failed to rerun '{s}' in fuzz mode: {t}", .{ run.step.name, test_name, err }); | |
| 214 | 210 | return; |
| 215 | 211 | }, |
| 216 | 212 | }; |
| ... | ... | @@ -269,8 +265,10 @@ pub fn sendUpdate( |
| 269 | 265 | socket: *std.http.Server.WebSocket, |
| 270 | 266 | prev: *Previous, |
| 271 | 267 | ) !void { |
| 272 | fuzz.coverage_mutex.lock(); | |
| 273 | defer fuzz.coverage_mutex.unlock(); | |
| 268 | const io = fuzz.io; | |
| 269 | ||
| 270 | try fuzz.coverage_mutex.lock(io); | |
| 271 | defer fuzz.coverage_mutex.unlock(io); | |
| 274 | 272 | |
| 275 | 273 | const coverage_maps = fuzz.coverage_files.values(); |
| 276 | 274 | if (coverage_maps.len == 0) return; |
| ... | ... | @@ -331,30 +329,41 @@ pub fn sendUpdate( |
| 331 | 329 | } |
| 332 | 330 | |
| 333 | 331 | fn coverageRun(fuzz: *Fuzz) void { |
| 334 | fuzz.queue_mutex.lock(); | |
| 335 | defer fuzz.queue_mutex.unlock(); | |
| 332 | coverageRunCancelable(fuzz) catch |err| switch (err) { | |
| 333 | error.Canceled => return, | |
| 334 | }; | |
| 335 | } | |
| 336 | ||
| 337 | fn coverageRunCancelable(fuzz: *Fuzz) Io.Cancelable!void { | |
| 338 | const io = fuzz.io; | |
| 339 | ||
| 340 | try fuzz.queue_mutex.lock(io); | |
| 341 | defer fuzz.queue_mutex.unlock(io); | |
| 336 | 342 | |
| 337 | 343 | while (true) { |
| 338 | fuzz.queue_cond.wait(&fuzz.queue_mutex); | |
| 344 | try fuzz.queue_cond.wait(io, &fuzz.queue_mutex); | |
| 339 | 345 | for (fuzz.msg_queue.items) |msg| switch (msg) { |
| 340 | 346 | .coverage => |coverage| prepareTables(fuzz, coverage.run, coverage.id) catch |err| switch (err) { |
| 341 | 347 | error.AlreadyReported => continue, |
| 342 | else => |e| log.err("failed to prepare code coverage tables: {s}", .{@errorName(e)}), | |
| 348 | error.Canceled => return, | |
| 349 | else => |e| log.err("failed to prepare code coverage tables: {t}", .{e}), | |
| 343 | 350 | }, |
| 344 | 351 | .entry_point => |entry_point| addEntryPoint(fuzz, entry_point.coverage_id, entry_point.addr) catch |err| switch (err) { |
| 345 | 352 | error.AlreadyReported => continue, |
| 346 | else => |e| log.err("failed to prepare code coverage tables: {s}", .{@errorName(e)}), | |
| 353 | error.Canceled => return, | |
| 354 | else => |e| log.err("failed to prepare code coverage tables: {t}", .{e}), | |
| 347 | 355 | }, |
| 348 | 356 | }; |
| 349 | 357 | fuzz.msg_queue.clearRetainingCapacity(); |
| 350 | 358 | } |
| 351 | 359 | } |
| 352 | fn prepareTables(fuzz: *Fuzz, run_step: *Step.Run, coverage_id: u64) error{ OutOfMemory, AlreadyReported }!void { | |
| 360 | fn prepareTables(fuzz: *Fuzz, run_step: *Step.Run, coverage_id: u64) error{ OutOfMemory, AlreadyReported, Canceled }!void { | |
| 353 | 361 | assert(fuzz.mode == .forever); |
| 354 | 362 | const ws = fuzz.mode.forever.ws; |
| 363 | const io = fuzz.io; | |
| 355 | 364 | |
| 356 | fuzz.coverage_mutex.lock(); | |
| 357 | defer fuzz.coverage_mutex.unlock(); | |
| 365 | try fuzz.coverage_mutex.lock(io); | |
| 366 | defer fuzz.coverage_mutex.unlock(io); | |
| 358 | 367 | |
| 359 | 368 | const gop = try fuzz.coverage_files.getOrPut(fuzz.gpa, coverage_id); |
| 360 | 369 | if (gop.found_existing) { |
| ... | ... | @@ -385,8 +394,8 @@ fn prepareTables(fuzz: *Fuzz, run_step: *Step.Run, coverage_id: u64) error{ OutO |
| 385 | 394 | target.ofmt, |
| 386 | 395 | target.cpu.arch, |
| 387 | 396 | ) catch |err| { |
| 388 | log.err("step '{s}': failed to load debug information for '{f}': {s}", .{ | |
| 389 | run_step.step.name, rebuilt_exe_path, @errorName(err), | |
| 397 | log.err("step '{s}': failed to load debug information for '{f}': {t}", .{ | |
| 398 | run_step.step.name, rebuilt_exe_path, err, | |
| 390 | 399 | }); |
| 391 | 400 | return error.AlreadyReported; |
| 392 | 401 | }; |
| ... | ... | @@ -397,15 +406,15 @@ fn prepareTables(fuzz: *Fuzz, run_step: *Step.Run, coverage_id: u64) error{ OutO |
| 397 | 406 | .sub_path = "v/" ++ std.fmt.hex(coverage_id), |
| 398 | 407 | }; |
| 399 | 408 | var coverage_file = coverage_file_path.root_dir.handle.openFile(coverage_file_path.sub_path, .{}) catch |err| { |
| 400 | log.err("step '{s}': failed to load coverage file '{f}': {s}", .{ | |
| 401 | run_step.step.name, coverage_file_path, @errorName(err), | |
| 409 | log.err("step '{s}': failed to load coverage file '{f}': {t}", .{ | |
| 410 | run_step.step.name, coverage_file_path, err, | |
| 402 | 411 | }); |
| 403 | 412 | return error.AlreadyReported; |
| 404 | 413 | }; |
| 405 | 414 | defer coverage_file.close(); |
| 406 | 415 | |
| 407 | 416 | const file_size = coverage_file.getEndPos() catch |err| { |
| 408 | log.err("unable to check len of coverage file '{f}': {s}", .{ coverage_file_path, @errorName(err) }); | |
| 417 | log.err("unable to check len of coverage file '{f}': {t}", .{ coverage_file_path, err }); | |
| 409 | 418 | return error.AlreadyReported; |
| 410 | 419 | }; |
| 411 | 420 | |
| ... | ... | @@ -417,7 +426,7 @@ fn prepareTables(fuzz: *Fuzz, run_step: *Step.Run, coverage_id: u64) error{ OutO |
| 417 | 426 | coverage_file.handle, |
| 418 | 427 | 0, |
| 419 | 428 | ) catch |err| { |
| 420 | log.err("failed to map coverage file '{f}': {s}", .{ coverage_file_path, @errorName(err) }); | |
| 429 | log.err("failed to map coverage file '{f}': {t}", .{ coverage_file_path, err }); | |
| 421 | 430 | return error.AlreadyReported; |
| 422 | 431 | }; |
| 423 | 432 | gop.value_ptr.mapped_memory = mapped_memory; |
| ... | ... | @@ -443,7 +452,7 @@ fn prepareTables(fuzz: *Fuzz, run_step: *Step.Run, coverage_id: u64) error{ OutO |
| 443 | 452 | }{ .addrs = sorted_pcs.items(.pc) }); |
| 444 | 453 | |
| 445 | 454 | debug_info.resolveAddresses(fuzz.gpa, sorted_pcs.items(.pc), sorted_pcs.items(.sl)) catch |err| { |
| 446 | log.err("failed to resolve addresses to source locations: {s}", .{@errorName(err)}); | |
| 455 | log.err("failed to resolve addresses to source locations: {t}", .{err}); | |
| 447 | 456 | return error.AlreadyReported; |
| 448 | 457 | }; |
| 449 | 458 | |
| ... | ... | @@ -453,9 +462,11 @@ fn prepareTables(fuzz: *Fuzz, run_step: *Step.Run, coverage_id: u64) error{ OutO |
| 453 | 462 | ws.notifyUpdate(); |
| 454 | 463 | } |
| 455 | 464 | |
| 456 | fn addEntryPoint(fuzz: *Fuzz, coverage_id: u64, addr: u64) error{ AlreadyReported, OutOfMemory }!void { | |
| 457 | fuzz.coverage_mutex.lock(); | |
| 458 | defer fuzz.coverage_mutex.unlock(); | |
| 465 | fn addEntryPoint(fuzz: *Fuzz, coverage_id: u64, addr: u64) error{ AlreadyReported, OutOfMemory, Canceled }!void { | |
| 466 | const io = fuzz.io; | |
| 467 | ||
| 468 | try fuzz.coverage_mutex.lock(io); | |
| 469 | defer fuzz.coverage_mutex.unlock(io); | |
| 459 | 470 | |
| 460 | 471 | const coverage_map = fuzz.coverage_files.getPtr(coverage_id).?; |
| 461 | 472 | const header: *const abi.SeenPcsHeader = @ptrCast(coverage_map.mapped_memory[0..@sizeOf(abi.SeenPcsHeader)]); |
| ... | ... | @@ -518,8 +529,8 @@ pub fn waitAndPrintReport(fuzz: *Fuzz) void { |
| 518 | 529 | .sub_path = "v/" ++ std.fmt.hex(cov.id), |
| 519 | 530 | }; |
| 520 | 531 | var coverage_file = coverage_file_path.root_dir.handle.openFile(coverage_file_path.sub_path, .{}) catch |err| { |
| 521 | fatal("step '{s}': failed to load coverage file '{f}': {s}", .{ | |
| 522 | cov.run.step.name, coverage_file_path, @errorName(err), | |
| 532 | fatal("step '{s}': failed to load coverage file '{f}': {t}", .{ | |
| 533 | cov.run.step.name, coverage_file_path, err, | |
| 523 | 534 | }); |
| 524 | 535 | }; |
| 525 | 536 | defer coverage_file.close(); |
| ... | ... | @@ -530,8 +541,8 @@ pub fn waitAndPrintReport(fuzz: *Fuzz) void { |
| 530 | 541 | |
| 531 | 542 | var header: fuzz_abi.SeenPcsHeader = undefined; |
| 532 | 543 | r.interface.readSliceAll(std.mem.asBytes(&header)) catch |err| { |
| 533 | fatal("step '{s}': failed to read from coverage file '{f}': {s}", .{ | |
| 534 | cov.run.step.name, coverage_file_path, @errorName(err), | |
| 544 | fatal("step '{s}': failed to read from coverage file '{f}': {t}", .{ | |
| 545 | cov.run.step.name, coverage_file_path, err, | |
| 535 | 546 | }); |
| 536 | 547 | }; |
| 537 | 548 | |
| ... | ... | @@ -545,8 +556,8 @@ pub fn waitAndPrintReport(fuzz: *Fuzz) void { |
| 545 | 556 | const chunk_count = fuzz_abi.SeenPcsHeader.seenElemsLen(header.pcs_len); |
| 546 | 557 | for (0..chunk_count) |_| { |
| 547 | 558 | const seen = r.interface.takeInt(usize, .little) catch |err| { |
| 548 | fatal("step '{s}': failed to read from coverage file '{f}': {s}", .{ | |
| 549 | cov.run.step.name, coverage_file_path, @errorName(err), | |
| 559 | fatal("step '{s}': failed to read from coverage file '{f}': {t}", .{ | |
| 560 | cov.run.step.name, coverage_file_path, err, | |
| 550 | 561 | }); |
| 551 | 562 | }; |
| 552 | 563 | seen_count += @popCount(seen); |
lib/std/Build/Step.zig+19-18| ... | ... | @@ -362,7 +362,7 @@ pub fn captureChildProcess( |
| 362 | 362 | .allocator = arena, |
| 363 | 363 | .argv = argv, |
| 364 | 364 | .progress_node = progress_node, |
| 365 | }) catch |err| return s.fail("failed to run {s}: {s}", .{ argv[0], @errorName(err) }); | |
| 365 | }) catch |err| return s.fail("failed to run {s}: {t}", .{ argv[0], err }); | |
| 366 | 366 | |
| 367 | 367 | if (result.stderr.len > 0) { |
| 368 | 368 | try s.result_error_msgs.append(arena, result.stderr); |
| ... | ... | @@ -412,7 +412,7 @@ pub fn evalZigProcess( |
| 412 | 412 | error.BrokenPipe => { |
| 413 | 413 | // Process restart required. |
| 414 | 414 | const term = zp.child.wait() catch |e| { |
| 415 | return s.fail("unable to wait for {s}: {s}", .{ argv[0], @errorName(e) }); | |
| 415 | return s.fail("unable to wait for {s}: {t}", .{ argv[0], e }); | |
| 416 | 416 | }; |
| 417 | 417 | _ = term; |
| 418 | 418 | s.clearZigProcess(gpa); |
| ... | ... | @@ -428,7 +428,7 @@ pub fn evalZigProcess( |
| 428 | 428 | if (s.result_error_msgs.items.len > 0 and result == null) { |
| 429 | 429 | // Crash detected. |
| 430 | 430 | const term = zp.child.wait() catch |e| { |
| 431 | return s.fail("unable to wait for {s}: {s}", .{ argv[0], @errorName(e) }); | |
| 431 | return s.fail("unable to wait for {s}: {t}", .{ argv[0], e }); | |
| 432 | 432 | }; |
| 433 | 433 | s.result_peak_rss = zp.child.resource_usage_statistics.getMaxRss() orelse 0; |
| 434 | 434 | s.clearZigProcess(gpa); |
| ... | ... | @@ -453,9 +453,7 @@ pub fn evalZigProcess( |
| 453 | 453 | child.request_resource_usage_statistics = true; |
| 454 | 454 | child.progress_node = prog_node; |
| 455 | 455 | |
| 456 | child.spawn() catch |err| return s.fail("failed to spawn zig compiler {s}: {s}", .{ | |
| 457 | argv[0], @errorName(err), | |
| 458 | }); | |
| 456 | child.spawn() catch |err| return s.fail("failed to spawn zig compiler {s}: {t}", .{ argv[0], err }); | |
| 459 | 457 | |
| 460 | 458 | const zp = try gpa.create(ZigProcess); |
| 461 | 459 | zp.* = .{ |
| ... | ... | @@ -480,7 +478,7 @@ pub fn evalZigProcess( |
| 480 | 478 | zp.child.stdin = null; |
| 481 | 479 | |
| 482 | 480 | const term = zp.child.wait() catch |err| { |
| 483 | return s.fail("unable to wait for {s}: {s}", .{ argv[0], @errorName(err) }); | |
| 481 | return s.fail("unable to wait for {s}: {t}", .{ argv[0], err }); | |
| 484 | 482 | }; |
| 485 | 483 | s.result_peak_rss = zp.child.resource_usage_statistics.getMaxRss() orelse 0; |
| 486 | 484 | |
| ... | ... | @@ -513,8 +511,8 @@ pub fn installFile(s: *Step, src_lazy_path: Build.LazyPath, dest_path: []const u |
| 513 | 511 | const src_path = src_lazy_path.getPath3(b, s); |
| 514 | 512 | try handleVerbose(b, null, &.{ "install", "-C", b.fmt("{f}", .{src_path}), dest_path }); |
| 515 | 513 | return Io.Dir.updateFile(src_path.root_dir.handle.adaptToNewApi(), io, src_path.sub_path, .cwd(), dest_path, .{}) catch |err| { |
| 516 | return s.fail("unable to update file from '{f}' to '{s}': {s}", .{ | |
| 517 | src_path, dest_path, @errorName(err), | |
| 514 | return s.fail("unable to update file from '{f}' to '{s}': {t}", .{ | |
| 515 | src_path, dest_path, err, | |
| 518 | 516 | }); |
| 519 | 517 | }; |
| 520 | 518 | } |
| ... | ... | @@ -524,9 +522,7 @@ pub fn installDir(s: *Step, dest_path: []const u8) !std.fs.Dir.MakePathStatus { |
| 524 | 522 | const b = s.owner; |
| 525 | 523 | try handleVerbose(b, null, &.{ "install", "-d", dest_path }); |
| 526 | 524 | return std.fs.cwd().makePathStatus(dest_path) catch |err| { |
| 527 | return s.fail("unable to create dir '{s}': {s}", .{ | |
| 528 | dest_path, @errorName(err), | |
| 529 | }); | |
| 525 | return s.fail("unable to create dir '{s}': {t}", .{ dest_path, err }); | |
| 530 | 526 | }; |
| 531 | 527 | } |
| 532 | 528 | |
| ... | ... | @@ -825,22 +821,27 @@ pub fn cacheHitAndWatch(s: *Step, man: *Build.Cache.Manifest) !bool { |
| 825 | 821 | return is_hit; |
| 826 | 822 | } |
| 827 | 823 | |
| 828 | fn failWithCacheError(s: *Step, man: *const Build.Cache.Manifest, err: Build.Cache.Manifest.HitError) error{ OutOfMemory, MakeFailed } { | |
| 824 | fn failWithCacheError( | |
| 825 | s: *Step, | |
| 826 | man: *const Build.Cache.Manifest, | |
| 827 | err: Build.Cache.Manifest.HitError, | |
| 828 | ) error{ OutOfMemory, Canceled, MakeFailed } { | |
| 829 | 829 | switch (err) { |
| 830 | 830 | error.CacheCheckFailed => switch (man.diagnostic) { |
| 831 | 831 | .none => unreachable, |
| 832 | .manifest_create, .manifest_read, .manifest_lock => |e| return s.fail("failed to check cache: {s} {s}", .{ | |
| 833 | @tagName(man.diagnostic), @errorName(e), | |
| 832 | .manifest_create, .manifest_read, .manifest_lock => |e| return s.fail("failed to check cache: {t} {t}", .{ | |
| 833 | man.diagnostic, e, | |
| 834 | 834 | }), |
| 835 | 835 | .file_open, .file_stat, .file_read, .file_hash => |op| { |
| 836 | 836 | const pp = man.files.keys()[op.file_index].prefixed_path; |
| 837 | 837 | const prefix = man.cache.prefixes()[pp.prefix].path orelse ""; |
| 838 | return s.fail("failed to check cache: '{s}{c}{s}' {s} {s}", .{ | |
| 839 | prefix, std.fs.path.sep, pp.sub_path, @tagName(man.diagnostic), @errorName(op.err), | |
| 838 | return s.fail("failed to check cache: '{s}{c}{s}' {t} {t}", .{ | |
| 839 | prefix, std.fs.path.sep, pp.sub_path, man.diagnostic, op.err, | |
| 840 | 840 | }); |
| 841 | 841 | }, |
| 842 | 842 | }, |
| 843 | 843 | error.OutOfMemory => return error.OutOfMemory, |
| 844 | error.Canceled => return error.Canceled, | |
| 844 | 845 | error.InvalidFormat => return s.fail("failed to check cache: invalid manifest file format", .{}), |
| 845 | 846 | } |
| 846 | 847 | } |
| ... | ... | @@ -850,7 +851,7 @@ fn failWithCacheError(s: *Step, man: *const Build.Cache.Manifest, err: Build.Cac |
| 850 | 851 | pub fn writeManifest(s: *Step, man: *Build.Cache.Manifest) !void { |
| 851 | 852 | if (s.test_results.isSuccess()) { |
| 852 | 853 | man.writeManifest() catch |err| { |
| 853 | try s.addError("unable to write cache manifest: {s}", .{@errorName(err)}); | |
| 854 | try s.addError("unable to write cache manifest: {t}", .{err}); | |
| 854 | 855 | }; |
| 855 | 856 | } |
| 856 | 857 | } |
lib/std/Build/Step/Run.zig+7-6| ... | ... | @@ -1830,6 +1830,7 @@ fn pollZigTest( |
| 1830 | 1830 | } { |
| 1831 | 1831 | const gpa = run.step.owner.allocator; |
| 1832 | 1832 | const arena = run.step.owner.allocator; |
| 1833 | const io = run.step.owner.graph.io; | |
| 1833 | 1834 | |
| 1834 | 1835 | var sub_prog_node: ?std.Progress.Node = null; |
| 1835 | 1836 | defer if (sub_prog_node) |n| n.end(); |
| ... | ... | @@ -2035,8 +2036,8 @@ fn pollZigTest( |
| 2035 | 2036 | |
| 2036 | 2037 | { |
| 2037 | 2038 | const fuzz = fuzz_context.?.fuzz; |
| 2038 | fuzz.queue_mutex.lock(); | |
| 2039 | defer fuzz.queue_mutex.unlock(); | |
| 2039 | fuzz.queue_mutex.lockUncancelable(io); | |
| 2040 | defer fuzz.queue_mutex.unlock(io); | |
| 2040 | 2041 | try fuzz.msg_queue.append(fuzz.gpa, .{ .coverage = .{ |
| 2041 | 2042 | .id = coverage_id.?, |
| 2042 | 2043 | .cumulative = .{ |
| ... | ... | @@ -2046,20 +2047,20 @@ fn pollZigTest( |
| 2046 | 2047 | }, |
| 2047 | 2048 | .run = run, |
| 2048 | 2049 | } }); |
| 2049 | fuzz.queue_cond.signal(); | |
| 2050 | fuzz.queue_cond.signal(io); | |
| 2050 | 2051 | } |
| 2051 | 2052 | }, |
| 2052 | 2053 | .fuzz_start_addr => { |
| 2053 | 2054 | const fuzz = fuzz_context.?.fuzz; |
| 2054 | 2055 | const addr = body_r.takeInt(u64, .little) catch unreachable; |
| 2055 | 2056 | { |
| 2056 | fuzz.queue_mutex.lock(); | |
| 2057 | defer fuzz.queue_mutex.unlock(); | |
| 2057 | fuzz.queue_mutex.lockUncancelable(io); | |
| 2058 | defer fuzz.queue_mutex.unlock(io); | |
| 2058 | 2059 | try fuzz.msg_queue.append(fuzz.gpa, .{ .entry_point = .{ |
| 2059 | 2060 | .addr = addr, |
| 2060 | 2061 | .coverage_id = coverage_id.?, |
| 2061 | 2062 | } }); |
| 2062 | fuzz.queue_cond.signal(); | |
| 2063 | fuzz.queue_cond.signal(io); | |
| 2063 | 2064 | } |
| 2064 | 2065 | }, |
| 2065 | 2066 | else => {}, // ignore other messages |
lib/std/Build/WebServer.zig+44-33| ... | ... | @@ -19,7 +19,7 @@ step_names_trailing: []u8, |
| 19 | 19 | step_status_bits: []u8, |
| 20 | 20 | |
| 21 | 21 | fuzz: ?Fuzz, |
| 22 | time_report_mutex: std.Thread.Mutex, | |
| 22 | time_report_mutex: Io.Mutex, | |
| 23 | 23 | time_report_msgs: [][]u8, |
| 24 | 24 | time_report_update_times: []i64, |
| 25 | 25 | |
| ... | ... | @@ -33,9 +33,9 @@ build_status: std.atomic.Value(abi.BuildStatus), |
| 33 | 33 | /// an unreasonable number of packets. |
| 34 | 34 | update_id: std.atomic.Value(u32), |
| 35 | 35 | |
| 36 | runner_request_mutex: std.Thread.Mutex, | |
| 37 | runner_request_ready_cond: std.Thread.Condition, | |
| 38 | runner_request_empty_cond: std.Thread.Condition, | |
| 36 | runner_request_mutex: Io.Mutex, | |
| 37 | runner_request_ready_cond: Io.Condition, | |
| 38 | runner_request_empty_cond: Io.Condition, | |
| 39 | 39 | runner_request: ?RunnerRequest, |
| 40 | 40 | |
| 41 | 41 | /// If a client is not explicitly notified of changes with `notifyUpdate`, it will be sent updates |
| ... | ... | @@ -114,14 +114,14 @@ pub fn init(opts: Options) WebServer { |
| 114 | 114 | .step_status_bits = step_status_bits, |
| 115 | 115 | |
| 116 | 116 | .fuzz = null, |
| 117 | .time_report_mutex = .{}, | |
| 117 | .time_report_mutex = .init, | |
| 118 | 118 | .time_report_msgs = time_report_msgs, |
| 119 | 119 | .time_report_update_times = time_report_update_times, |
| 120 | 120 | |
| 121 | 121 | .build_status = .init(.idle), |
| 122 | 122 | .update_id = .init(0), |
| 123 | 123 | |
| 124 | .runner_request_mutex = .{}, | |
| 124 | .runner_request_mutex = .init, | |
| 125 | 125 | .runner_request_ready_cond = .{}, |
| 126 | 126 | .runner_request_empty_cond = .{}, |
| 127 | 127 | .runner_request = null, |
| ... | ... | @@ -296,6 +296,8 @@ fn accept(ws: *WebServer, stream: net.Stream) void { |
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | fn serveWebSocket(ws: *WebServer, sock: *http.Server.WebSocket) !noreturn { |
| 299 | const io = ws.graph.io; | |
| 300 | ||
| 299 | 301 | var prev_build_status = ws.build_status.load(.monotonic); |
| 300 | 302 | |
| 301 | 303 | const prev_step_status_bits = try ws.gpa.alloc(u8, ws.step_status_bits.len); |
| ... | ... | @@ -331,8 +333,8 @@ fn serveWebSocket(ws: *WebServer, sock: *http.Server.WebSocket) !noreturn { |
| 331 | 333 | } |
| 332 | 334 | |
| 333 | 335 | { |
| 334 | ws.time_report_mutex.lock(); | |
| 335 | defer ws.time_report_mutex.unlock(); | |
| 336 | try ws.time_report_mutex.lock(io); | |
| 337 | defer ws.time_report_mutex.unlock(io); | |
| 336 | 338 | for (ws.time_report_msgs, ws.time_report_update_times) |msg, update_time| { |
| 337 | 339 | if (update_time <= prev_time) continue; |
| 338 | 340 | // We want to send `msg`, but shouldn't block `ws.time_report_mutex` while we do, so |
| ... | ... | @@ -340,8 +342,8 @@ fn serveWebSocket(ws: *WebServer, sock: *http.Server.WebSocket) !noreturn { |
| 340 | 342 | const owned_msg = try ws.gpa.dupe(u8, msg); |
| 341 | 343 | defer ws.gpa.free(owned_msg); |
| 342 | 344 | // Temporarily unlock, then re-lock after the message is sent. |
| 343 | ws.time_report_mutex.unlock(); | |
| 344 | defer ws.time_report_mutex.lock(); | |
| 345 | ws.time_report_mutex.unlock(io); | |
| 346 | defer ws.time_report_mutex.lockUncancelable(io); | |
| 345 | 347 | try sock.writeMessage(owned_msg, .binary); |
| 346 | 348 | } |
| 347 | 349 | } |
| ... | ... | @@ -382,6 +384,8 @@ fn serveWebSocket(ws: *WebServer, sock: *http.Server.WebSocket) !noreturn { |
| 382 | 384 | } |
| 383 | 385 | } |
| 384 | 386 | fn recvWebSocketMessages(ws: *WebServer, sock: *http.Server.WebSocket) void { |
| 387 | const io = ws.graph.io; | |
| 388 | ||
| 385 | 389 | while (true) { |
| 386 | 390 | const msg = sock.readSmallMessage() catch return; |
| 387 | 391 | if (msg.opcode != .binary) continue; |
| ... | ... | @@ -390,14 +394,16 @@ fn recvWebSocketMessages(ws: *WebServer, sock: *http.Server.WebSocket) void { |
| 390 | 394 | switch (tag) { |
| 391 | 395 | _ => continue, |
| 392 | 396 | .rebuild => while (true) { |
| 393 | ws.runner_request_mutex.lock(); | |
| 394 | defer ws.runner_request_mutex.unlock(); | |
| 397 | ws.runner_request_mutex.lock(io) catch |err| switch (err) { | |
| 398 | error.Canceled => return, | |
| 399 | }; | |
| 400 | defer ws.runner_request_mutex.unlock(io); | |
| 395 | 401 | if (ws.runner_request == null) { |
| 396 | 402 | ws.runner_request = .rebuild; |
| 397 | ws.runner_request_ready_cond.signal(); | |
| 403 | ws.runner_request_ready_cond.signal(io); | |
| 398 | 404 | break; |
| 399 | 405 | } |
| 400 | ws.runner_request_empty_cond.wait(&ws.runner_request_mutex); | |
| 406 | ws.runner_request_empty_cond.wait(io, &ws.runner_request_mutex) catch return; | |
| 401 | 407 | }, |
| 402 | 408 | } |
| 403 | 409 | } |
| ... | ... | @@ -691,14 +697,15 @@ pub fn updateTimeReportCompile(ws: *WebServer, opts: struct { |
| 691 | 697 | trailing: []const u8, |
| 692 | 698 | }) void { |
| 693 | 699 | const gpa = ws.gpa; |
| 700 | const io = ws.graph.io; | |
| 694 | 701 | |
| 695 | 702 | const step_idx: u32 = for (ws.all_steps, 0..) |s, i| { |
| 696 | 703 | if (s == &opts.compile.step) break @intCast(i); |
| 697 | 704 | } else unreachable; |
| 698 | 705 | |
| 699 | 706 | const old_buf = old: { |
| 700 | ws.time_report_mutex.lock(); | |
| 701 | defer ws.time_report_mutex.unlock(); | |
| 707 | ws.time_report_mutex.lock(io) catch return; | |
| 708 | defer ws.time_report_mutex.unlock(io); | |
| 702 | 709 | const old = ws.time_report_msgs[step_idx]; |
| 703 | 710 | ws.time_report_msgs[step_idx] = &.{}; |
| 704 | 711 | break :old old; |
| ... | ... | @@ -720,8 +727,8 @@ pub fn updateTimeReportCompile(ws: *WebServer, opts: struct { |
| 720 | 727 | @memcpy(buf[@sizeOf(abi.time_report.CompileResult)..], opts.trailing); |
| 721 | 728 | |
| 722 | 729 | { |
| 723 | ws.time_report_mutex.lock(); | |
| 724 | defer ws.time_report_mutex.unlock(); | |
| 730 | ws.time_report_mutex.lock(io) catch return; | |
| 731 | defer ws.time_report_mutex.unlock(io); | |
| 725 | 732 | assert(ws.time_report_msgs[step_idx].len == 0); |
| 726 | 733 | ws.time_report_msgs[step_idx] = buf; |
| 727 | 734 | ws.time_report_update_times[step_idx] = ws.now(); |
| ... | ... | @@ -731,14 +738,15 @@ pub fn updateTimeReportCompile(ws: *WebServer, opts: struct { |
| 731 | 738 | |
| 732 | 739 | pub fn updateTimeReportGeneric(ws: *WebServer, step: *Build.Step, ns_total: u64) void { |
| 733 | 740 | const gpa = ws.gpa; |
| 741 | const io = ws.graph.io; | |
| 734 | 742 | |
| 735 | 743 | const step_idx: u32 = for (ws.all_steps, 0..) |s, i| { |
| 736 | 744 | if (s == step) break @intCast(i); |
| 737 | 745 | } else unreachable; |
| 738 | 746 | |
| 739 | 747 | const old_buf = old: { |
| 740 | ws.time_report_mutex.lock(); | |
| 741 | defer ws.time_report_mutex.unlock(); | |
| 748 | ws.time_report_mutex.lock(io) catch return; | |
| 749 | defer ws.time_report_mutex.unlock(io); | |
| 742 | 750 | const old = ws.time_report_msgs[step_idx]; |
| 743 | 751 | ws.time_report_msgs[step_idx] = &.{}; |
| 744 | 752 | break :old old; |
| ... | ... | @@ -750,8 +758,8 @@ pub fn updateTimeReportGeneric(ws: *WebServer, step: *Build.Step, ns_total: u64) |
| 750 | 758 | .ns_total = ns_total, |
| 751 | 759 | }; |
| 752 | 760 | { |
| 753 | ws.time_report_mutex.lock(); | |
| 754 | defer ws.time_report_mutex.unlock(); | |
| 761 | ws.time_report_mutex.lock(io) catch return; | |
| 762 | defer ws.time_report_mutex.unlock(io); | |
| 755 | 763 | assert(ws.time_report_msgs[step_idx].len == 0); |
| 756 | 764 | ws.time_report_msgs[step_idx] = buf; |
| 757 | 765 | ws.time_report_update_times[step_idx] = ws.now(); |
| ... | ... | @@ -766,6 +774,7 @@ pub fn updateTimeReportRunTest( |
| 766 | 774 | ns_per_test: []const u64, |
| 767 | 775 | ) void { |
| 768 | 776 | const gpa = ws.gpa; |
| 777 | const io = ws.graph.io; | |
| 769 | 778 | |
| 770 | 779 | const step_idx: u32 = for (ws.all_steps, 0..) |s, i| { |
| 771 | 780 | if (s == &run.step) break @intCast(i); |
| ... | ... | @@ -782,8 +791,8 @@ pub fn updateTimeReportRunTest( |
| 782 | 791 | break :len @sizeOf(abi.time_report.RunTestResult) + names_len + 8 * tests_len; |
| 783 | 792 | }; |
| 784 | 793 | const old_buf = old: { |
| 785 | ws.time_report_mutex.lock(); | |
| 786 | defer ws.time_report_mutex.unlock(); | |
| 794 | ws.time_report_mutex.lock(io) catch return; | |
| 795 | defer ws.time_report_mutex.unlock(io); | |
| 787 | 796 | const old = ws.time_report_msgs[step_idx]; |
| 788 | 797 | ws.time_report_msgs[step_idx] = &.{}; |
| 789 | 798 | break :old old; |
| ... | ... | @@ -808,8 +817,8 @@ pub fn updateTimeReportRunTest( |
| 808 | 817 | assert(offset == buf.len); |
| 809 | 818 | |
| 810 | 819 | { |
| 811 | ws.time_report_mutex.lock(); | |
| 812 | defer ws.time_report_mutex.unlock(); | |
| 820 | ws.time_report_mutex.lock(io) catch return; | |
| 821 | defer ws.time_report_mutex.unlock(io); | |
| 813 | 822 | assert(ws.time_report_msgs[step_idx].len == 0); |
| 814 | 823 | ws.time_report_msgs[step_idx] = buf; |
| 815 | 824 | ws.time_report_update_times[step_idx] = ws.now(); |
| ... | ... | @@ -821,8 +830,9 @@ const RunnerRequest = union(enum) { |
| 821 | 830 | rebuild, |
| 822 | 831 | }; |
| 823 | 832 | pub fn getRunnerRequest(ws: *WebServer) ?RunnerRequest { |
| 824 | ws.runner_request_mutex.lock(); | |
| 825 | defer ws.runner_request_mutex.unlock(); | |
| 833 | const io = ws.graph.io; | |
| 834 | ws.runner_request_mutex.lock(io) catch return; | |
| 835 | defer ws.runner_request_mutex.unlock(io); | |
| 826 | 836 | if (ws.runner_request) |req| { |
| 827 | 837 | ws.runner_request = null; |
| 828 | 838 | ws.runner_request_empty_cond.signal(); |
| ... | ... | @@ -830,16 +840,17 @@ pub fn getRunnerRequest(ws: *WebServer) ?RunnerRequest { |
| 830 | 840 | } |
| 831 | 841 | return null; |
| 832 | 842 | } |
| 833 | pub fn wait(ws: *WebServer) RunnerRequest { | |
| 834 | ws.runner_request_mutex.lock(); | |
| 835 | defer ws.runner_request_mutex.unlock(); | |
| 843 | pub fn wait(ws: *WebServer) Io.Cancelable!RunnerRequest { | |
| 844 | const io = ws.graph.io; | |
| 845 | try ws.runner_request_mutex.lock(io); | |
| 846 | defer ws.runner_request_mutex.unlock(io); | |
| 836 | 847 | while (true) { |
| 837 | 848 | if (ws.runner_request) |req| { |
| 838 | 849 | ws.runner_request = null; |
| 839 | ws.runner_request_empty_cond.signal(); | |
| 850 | ws.runner_request_empty_cond.signal(io); | |
| 840 | 851 | return req; |
| 841 | 852 | } |
| 842 | ws.runner_request_ready_cond.wait(&ws.runner_request_mutex); | |
| 853 | try ws.runner_request_ready_cond.wait(io, &ws.runner_request_mutex); | |
| 843 | 854 | } |
| 844 | 855 | } |
| 845 | 856 |