summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Brolley <brolley@redhat.com>2008-08-11 15:54:45 -0400
committerDave Brolley <brolley@redhat.com>2008-08-11 15:54:45 -0400
commit32a1dfe9c13094391dab645484e7563992f9ba53 (patch)
tree039ae20b62771e00fa055e0c7b61ac28c7a99ee3
parentb391a1e0499d3cbafde11beeba8fb385465c1e64 (diff)
downloadsystemtap-steved-32a1dfe9c13094391dab645484e7563992f9ba53.tar.gz
systemtap-steved-32a1dfe9c13094391dab645484e7563992f9ba53.tar.xz
systemtap-steved-32a1dfe9c13094391dab645484e7563992f9ba53.zip
stap-serverd was incorectly determining that the server could
not be started.
-rw-r--r--ChangeLog9
-rwxr-xr-xstap-client2
-rwxr-xr-xstap-server10
-rwxr-xr-xstap-serverd27
4 files changed, 34 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index 56bc9990..9e40f1e7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
}