From 7fd99442c746043a812348f4477180814f98b005 Mon Sep 17 00:00:00 2001 From: chenglch Date: Tue, 1 Mar 2016 04:53:50 -0500 Subject: [PATCH] Fix race condition issue when printing message in xcatd related-issue: #729 related-commit: #742 --- xCAT-server/sbin/xcatd | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/xCAT-server/sbin/xcatd b/xCAT-server/sbin/xcatd index 91ee34c19..a44296cd9 100644 --- a/xCAT-server/sbin/xcatd +++ b/xCAT-server/sbin/xcatd @@ -1897,15 +1897,20 @@ sub plugin_command { $xcatresponses{xcatresponse}=[]; } } + if (scalar(@{$xcatresponses{xcatresponse}})) { + send_response(\%xcatresponses,$sock); + $xcatresponses{xcatresponse}=[]; + } if ($check_fds->count > 0) { my %resp_timeout = ('errorcode'=>[1], 'data'=>["Warning: Process terminated due to IO timeout, the following output may not complete.\n"]); push @{$xcatresponses{xcatresponse}},\%resp_timeout; + my $count = scalar(@{$xcatresponses{xcatresponse}}); relay_fds($check_fds,$xcatresponses{xcatresponse}); - } - if (scalar(@{$xcatresponses{xcatresponse}})) { - send_response(\%xcatresponses,$sock); - $xcatresponses{xcatresponse}=[]; + if (scalar(@{$xcatresponses{xcatresponse}}) != $count) { + send_response(\%xcatresponses,$sock); + $xcatresponses{xcatresponse}=[]; + } } #while (relay_fds($check_fds,$sock)) {}