diff options
-rw-r--r-- | ChangeLog | 9 | ||||
-rwxr-xr-x | stap-client | 2 | ||||
-rwxr-xr-x | stap-server | 10 | ||||
-rwxr-xr-x | stap-serverd | 27 |
4 files changed, 34 insertions, 14 deletions
@@ -1,3 +1,12 @@ +2008-08-11 Dave Brolley <brolley@redhat.com> + + * stap-client (disconnect_from_server): Call after receive_response. + * stap-server (stap_rc): Renamed from 'rc'. Don't use it as an exit + code. + * stap-serverd (listen): Set pipefail so that we get the rc of nc + if it fails. Make multiple attempts to establish a server. + (fatal): Call 'terminate'. + 2008-08-11 Frank Ch. Eigler <fche@elastic.org> PR5049 diff --git a/stap-client b/stap-client index cb9bd888..405692f1 100755 --- a/stap-client +++ b/stap-client @@ -666,8 +666,8 @@ package_request find_and_connect_to_server send_request receive_response -unpack_response disconnect_from_server +unpack_response stream_output maybe_call_staprun cleanup diff --git a/stap-server b/stap-server index fb4203b6..15a2fb48 100755 --- a/stap-server +++ b/stap-server @@ -31,7 +31,7 @@ function configuration { # function: initialization function initialization { # Initialization - rc=0 + stap_rc=0 wd=`pwd` # Default options settings @@ -340,7 +340,7 @@ function call_stap { >> $tmpdir_server/stdout \ 2>> $tmpdir_server/stderr - rc=$? + stap_rc=$? } # function: create_response @@ -401,7 +401,7 @@ function send_response { # early if stdin from the other side is not provided. nc -l $port < $tar_server > /dev/null & - if test $rc = 0; then + if test $stap_rc = 0; then echo "done:" else echo "failed:" @@ -449,7 +449,7 @@ function cleanup { function terminate { # Clean up cleanup - exit $rc + exit 1 } #----------------------------------------------------------------------------- @@ -467,4 +467,4 @@ package_response send_response cleanup -exit $rc +exit 0 diff --git a/stap-serverd b/stap-serverd index 221f353f..32888ecc 100755 --- a/stap-serverd +++ b/stap-serverd @@ -65,21 +65,31 @@ function listen { # Loop forever accepting requests first=1 + set -o pipefail # We want the status of 'nc' not 'stap-server'. while true do # Run this in the background and wait for it. This way any signals # received (i.e. SIGTERM) will be processed. Make sure we don't # advertise our presence until we're actually listening. - nc -l $port < $fifo_name | stap-server $((port + 1)) > $fifo_name 2>&1 & - if test $first = 1; then - advertise_presence - first=0 + for ((attempt=0; $attempt < 5; ++attempt)) + do + nc -l $port < $fifo_name | stap-server $((port + 1)) > $fifo_name 2>&1 & + if test $first = 1; then + advertise_presence + first=0 + fi + wait %nc + rc=$? + if test $rc = 127 -o $rc = 0; then + break; # success + fi + sleep 1 + done + if test $attempt = 10; then + fatal "ERROR: cannot listen on port $port. rc==$rc" fi - wait %nc - if [ $? -ne 0 ]; then - fatal "ERROR: cannot listen on port $port" - fi done + set +o pipefail # restore } # function: fatal [ MESSAGE ] @@ -88,6 +98,7 @@ function listen { # Prints its arguments to stderr and exits function fatal { echo "$@" >&2 + terminate exit 1 } |