From 452d193a92d8288f50d01c0a7640aec1ab20fa4d Mon Sep 17 00:00:00 2001 From: miljenko Date: Fri, 9 Dec 2005 12:10:03 +0000 Subject: [PATCH] Removed bug in local "remote" execution. Bug found by: Submitted by: Requested by: Reviewed by: Approved by: Obtained from: --- exec.tcl | 55 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/exec.tcl b/exec.tcl index 921377f..e7a67c9 100755 --- a/exec.tcl +++ b/exec.tcl @@ -62,11 +62,21 @@ proc nexec { args } { tk_messageBox -title "Editor only" \ -message "Running in editor only mode. Cannot execute commands. Please report this problem." \ -type ok - exit 5 + ;#exit 5 + return "" } if { $remote_exec } { - if { ! $exec_sockets_opened } { open_exec_sockets } + if { ! $exec_sockets_opened } { + open_exec_sockets + if { ! [info exists exec_sock] } { + tk_messageBox -title "Editor only" \ + -message "Cannot open sockets.\nMode changed to \"editor only\"." \ + -type ok + set editor_only true + return "" + } + } set exec_results "" puts $exec_sock "$args" vwait exec_results_ready @@ -119,6 +129,7 @@ proc nexec_monitor { args } { proc open_exec_sockets {} { global exec_hosts remote_exec exec_sockets_opened global exec_host exec_port monitor_port exec_sock monitor_sock + global editor_only if { ! $remote_exec } { return } @@ -135,20 +146,25 @@ proc open_exec_sockets {} { } if { ! $remote_exec } { return } - set exec_sock [socket -async $exec_host $exec_port] - set monitor_sock [socket -async $exec_host $monitor_port] set fail true while {$fail} { - 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 - } + if { ! [info exists exec_sock] || ! [info exists monitor_sock] } { + catch {set exec_sock [socket -async $exec_host $exec_port]} + catch {set monitor_sock [socket -async $exec_host $monitor_port]} + } + + 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 + } + } } if { $fail } { @@ -156,6 +172,8 @@ proc open_exec_sockets {} { "Cannot open sockets {$exec_host,$exec_port|$monitor_port}" \ "" 0 "Retry" "Configure remote hosts" "Editor only mode" ] switch $sel { + 0 { ;# retry + } 1 { configRemoteHosts set at_least_one_up false set n [llength $exec_hosts] @@ -172,11 +190,6 @@ proc open_exec_sockets {} { set editor_only true .menubat.experiment entryconfigure \ "Execute" -state disabled - } else { - set exec_sock - [socket -async $exec_host $exec_port] - set monitor_sock - [socket -async $exec_host $monitor_port] } } @@ -200,6 +213,14 @@ proc setOperMode { mode } { global nmbufs nmbclusters global editor_only + if { $mode == "exec" } { ;# let's try something, sockets should be opened + nexec id -u + if { $editor_only } { ;# if set in nexec or open_exec_sockets + .menubar.experiment entryconfigure "Execute" -state disabled + return + } + } + # Verify that links to external interfaces are properly configured if { $mode == "exec" } { set extifcs [nexec ifconfig -l] -- 2.39.5