mtr - synchronize output between different threads on Windows.

An attempt to fix lost output sometimes seen on buildbot.
This commit is contained in:
Vladislav Vaintroub 2024-01-26 14:37:26 +01:00
parent d912a6369c
commit 5abf0fea51

View file

@ -87,12 +87,16 @@ sub flush_out {
$out_line = ""; $out_line = "";
} }
use if $^O eq "MSWin32", "threads::shared";
my $flush_lock :shared;
# Print to stdout # Print to stdout
sub print_out { sub print_out {
if(IS_WIN32PERL) { if(IS_WIN32PERL) {
$out_line .= $_[0]; $out_line .= $_[0];
# Flush buffered output on new lines. # Flush buffered output on new lines.
if (rindex($_[0], "\n") != -1) { if (rindex($_[0], "\n") != -1) {
lock($flush_lock);
flush_out(); flush_out();
} }
} else { } else {