[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[patch] spurious fails with rsh target
From: |
Felix Lee |
Subject: |
[patch] spurious fails with rsh target |
Date: |
Mon, 24 Jan 2005 13:47:28 -0800 |
symptom: when using rsh to talk to a target board, I get dozens
of FAILs and UNRESOLVEDs because of failure to send program to
target, failure to execute command on target, etc. runtest -v,
the error message from rsh is something like "rcmd: socket: All
ports in use".
what happens is rsh wants to allocate a "privileged" port<1024 on
the local machine, and the tcp protocol requires a port to stay
allocated for 2min after the connection is closed, and the target
machine is fast enough that hundreds of rsh and rcp happen in
less than 2min, so I run out of unallocated ports<1024.
one workaround is to use ssh instead of rsh, since ssh will use
ports>=1024.
another workaround is to retry the rsh a couple times before
giving up, which is the patch below.
it might be nice if rsh.exp tried to use a persistent rsh
connection, but that's a bigger change, and it will still need to
retry sometimes.
2005-01-10 Felix Lee <address@hidden>
* lib/rsh.exp (rsh_retry): New function.
(rsh_download, rsh_exec): Use it.
Index: lib/rsh.exp
===================================================================
RCS file: /services/cvs/cvsroot/gnusense/dejagnu/lib/rsh.exp,v
retrieving revision 1.1
retrieving revision 1.1.1.1.2.1
diff -b -u -p -r1.1 -r1.1.1.1.2.1
--- lib/rsh.exp 8 Jul 2004 12:14:50 -0000 1.1
+++ lib/rsh.exp 24 Jan 2005 21:16:22 -0000 1.1.1.1.2.1
@@ -183,8 +182,12 @@ proc rsh_download {desthost srcfile dest
set desthost [board_info $desthost hostname]
}
- set status [catch "exec $RSH $rsh_useropts $desthost rm -f $destfile |&
cat" output]
- set status [catch "exec $RCP $srcfile $rcp_user$desthost:$destfile |& cat"
output]
+ set exec "$RSH $rsh_useropts $desthost rm -f $destfile |& cat"
+ foreach {status output} [rsh_retry $exec] {}
+
+ set exec "$RCP $srcfile $rcp_user$desthost:$destfile |& cat"
+ foreach {status output} [rsh_retry $exec] {}
+
if { $status == 0 } {
verbose "Copied $srcfile to $desthost:$destfile" 2
return $destfile
@@ -215,7 +218,9 @@ proc rsh_upload {desthost srcfile destfi
set desthost [board_info $desthost hostname]
}
- set status [catch "exec $RCP $rcp_user$desthost:$srcfile $destfile" output]
+ set exec "$RCP $rcp_user$desthost:$srcfile $destfile"
+ foreach {status output} [rsh_retry $exec] {}
+
if { $status == 0 } {
verbose "Copied $desthost:$srcfile to $destfile" 2
return $destfile
@@ -276,9 +281,11 @@ proc rsh_exec { boardname cmd args } {
if { $inp == "" } {
set inp "/dev/null"
}
+ set exec [concat "cat $inp | $RSH $rsh_useropts $hostname" \
+ "{sh -c '$cmd $pargs ; echo XYZ\$?ZYX'}" \
+ "|& cat"]
+ foreach {status output} [rsh_retry $exec] {}
- set status [catch "exec cat $inp | $RSH $rsh_useropts $hostname sh -c
'$cmd $pargs \\; echo XYZ\\\${?}ZYX' |& cat" output]
- verbose "$RSH output is $output"
# `status' doesn't mean much here other than rsh worked ok.
# What we want is whether $cmd ran ok.
if { $status != 0 } {
@@ -295,4 +302,20 @@ proc rsh_exec { boardname cmd args } {
# to behave identical to it.
regsub "\n$" $output "" output
return [list [expr $status != 0] $output]
+}
+
+# a typical failure from rsh is "rcmd: socket: All ports in
+# use" which happens because rsh wants to use a port<1024,
+# and closed tcp sockets stay in TIME_WAIT state for 240s.
+
+proc rsh_retry {exec} {
+ for {set k 0} {$k < 5} {incr k} {
+ set status [catch [concat exec $exec] output]
+ verbose "rsh_retry got $status {$output} from {$exec}"
+ if {$status == 0} {
+ break
+ }
+ sleep 5
+ }
+ return [list $status $output]
}
- [patch] spurious fails with rsh target,
Felix Lee <=