From 7c1ce500aef335e375fa66f691c6ba24fa333c42 Mon Sep 17 00:00:00 2001 From: miljenko Date: Wed, 21 Dec 2005 07:43:21 +0000 Subject: [PATCH] remote execution code cleanup Bug found by: Submitted by: Requested by: Reviewed by: Approved by: Obtained from: --- exec.tcl | 47 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/exec.tcl b/exec.tcl index e7a67c9..a112912 100755 --- a/exec.tcl +++ b/exec.tcl @@ -156,15 +156,17 @@ proc open_exec_sockets {} { } if { [info exists exec_sock] && [info exists monitor_sock] } { - for { set i 1 } { $i <= 4 } { incr i } { - if {[lindex [fconfigure $exec_sock -sockname] 0] != "0.0.0.0" && - [lindex [fconfigure $monitor_sock -sockname] 0] != "0.0.0.0" } { - set fail false - break - } else { - after 250 ;# Max 2 sec for socket creation - } + for { set i 1 } { $i <= 4 } { incr i } { + if {([lindex [fconfigure $exec_sock -sockname] 0] != "0.0.0.0") && + ([lindex [fconfigure $monitor_sock -sockname] 0] != "0.0.0.0") + && ([catch {fconfigure $exec_sock -peername} a] == 0) + && ([catch {fconfigure $monitor_sock -peername} a] == 0) } { + set fail false + break + } else { + after 250 ;# Max 2 sec for socket creation } + } } if { $fail } { @@ -175,6 +177,7 @@ proc open_exec_sockets {} { 0 { ;# retry } 1 { configRemoteHosts + ;# Never comes back!? set at_least_one_up false set n [llength $exec_hosts] for { set i 0 } { $i < $n } { incr i } { @@ -188,12 +191,16 @@ proc open_exec_sockets {} { } if { $remote_exec && ! $at_least_one_up } { set editor_only true - .menubat.experiment entryconfigure \ + .menubar.experiment entryconfigure \ "Execute" -state disabled } } - 2 { set editor_only true; set fail false; return } + 2 { set editor_only true + .menubar.experiment entryconfigure "Execute" -state disabled + set fail false + return + } default { } } } @@ -507,7 +514,22 @@ proc deployCfg {} { close $fileId } else { nexec nc -l -p 1235 > /tmp/$node_id/boot.conf & - set s [socket $exec_host 1235] + ;# set s [socket $exec_host 1235] + catch {set s [socket -async $exec_host 1235]} + set fail true + for { set i 1 } { $i <= 4 } { incr i } { + if {[catch {fconfigure $s -peername} a] == 0 } { + set fail false + break + } else { + after 250 ;# Max 2 sec for socket creation + } + } + if { $fail } { + tk_messageBox -title "Boot file creation" \ + -message "Cannot open socket: $exec_host:1235 for boot file creation. \nPlease report this problem." -type ok + exit 5 + } fconfigure $s -buffering line -translation lf foreach line $bootcfg { puts $s $line @@ -515,7 +537,8 @@ proc deployCfg {} { flush $s close $s } - catch "nexec vimage $node_id $bootcmd /tmp/$node_id/boot.conf &" + ;# removed backgroud invocation + catch "nexec vimage $node_id $bootcmd /tmp/$node_id/boot.conf" } } -- 2.39.5