summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Brolley <brolley@redhat.com>2008-08-25 11:23:41 -0400
committerDave Brolley <brolley@redhat.com>2008-08-25 11:23:41 -0400
commitb593551607cc5b6ef512e787b0f881d99c4ac6c5 (patch)
tree67837d35b794a76a3d5d3cabfdeb3deac71a12d0
parent4550733ebf24fb067f9a2350e0ab86d44fea932e (diff)
downloadsystemtap-steved-b593551607cc5b6ef512e787b0f881d99c4ac6c5.tar.gz
systemtap-steved-b593551607cc5b6ef512e787b0f881d99c4ac6c5.tar.xz
systemtap-steved-b593551607cc5b6ef512e787b0f881d99c4ac6c5.zip
Robustness improvements for the stap client/server
-rw-r--r--Makefile.am2
-rw-r--r--Makefile.in27
-rw-r--r--aclocal.m438
-rw-r--r--doc/Makefile.in4
-rwxr-xr-xstap-client35
-rwxr-xr-xstap-server51
-rwxr-xr-xstap-serverd64
-rw-r--r--testsuite/Makefile.in8
8 files changed, 120 insertions, 109 deletions
diff --git a/Makefile.am b/Makefile.am
index 05da9fad..9cbaf747 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -248,7 +248,7 @@ installcheck:
echo "$(DESTDIR)$(bindir)/stap is not recent, run make install"; \
exit -1; \
fi;
- $(MAKE) -C testsuite installcheck RUNTESTFLAGS="$(RUNTESTFLAGS)" EXTRA_SYSTEMTAP_PATH="$(EXTRA_SYSTEMTAP_PATH)"
+ $(MAKE) -C testsuite installcheck RUNTESTFLAGS="$(RUNTESTFLAGS)"
rpm: systemtap.spec dist
rpmbuild --define "_sourcedir $(PWD)/" -ba $(srcdir)/systemtap.spec
diff --git a/Makefile.in b/Makefile.in
index 9de49415..93d723a7 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# Makefile.in generated by automake 1.10 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@@ -1164,8 +1164,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
- $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
- END { if (nonempty) { for (i in files) print i; }; }'`; \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
mkid -fID $$unique
tags: TAGS
@@ -1190,8 +1190,8 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES) config.in $(TAGS_DEPENDENCIES) \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
- $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
- END { if (nonempty) { for (i in files) print i; }; }'`; \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -1201,12 +1201,13 @@ ctags: CTAGS
CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.in $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
+ here=`pwd`; \
list='$(SOURCES) $(HEADERS) config.in $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
- $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
- END { if (nonempty) { for (i in files) print i; }; }'`; \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
@@ -1279,10 +1280,6 @@ dist-bzip2: distdir
tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
$(am__remove_distdir)
-dist-lzma: distdir
- tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma
- $(am__remove_distdir)
-
dist-tarZ: distdir
tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
$(am__remove_distdir)
@@ -1310,8 +1307,6 @@ distcheck: dist
GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\
*.tar.bz2*) \
bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\
- *.tar.lzma*) \
- unlzma -c $(distdir).tar.lzma | $(am__untar) ;;\
*.tar.Z*) \
uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
*.shar.gz*) \
@@ -1480,7 +1475,7 @@ uninstall-man: uninstall-man1 uninstall-man5 uninstall-man8
clean-binPROGRAMS clean-generic clean-local \
clean-noinstPROGRAMS clean-pkglibexecPROGRAMS ctags \
ctags-recursive dist dist-all dist-bzip2 dist-gzip dist-hook \
- dist-lzma dist-shar dist-tarZ dist-zip distcheck distclean \
+ dist-shar dist-tarZ dist-zip distcheck distclean \
distclean-compile distclean-generic distclean-hdr \
distclean-tags distcleancheck distdir distuninstallcheck dvi \
dvi-am html html-am info info-am install install-am \
@@ -1637,7 +1632,7 @@ installcheck:
echo "$(DESTDIR)$(bindir)/stap is not recent, run make install"; \
exit -1; \
fi;
- $(MAKE) -C testsuite installcheck RUNTESTFLAGS="$(RUNTESTFLAGS)" EXTRA_SYSTEMTAP_PATH="$(EXTRA_SYSTEMTAP_PATH)"
+ $(MAKE) -C testsuite installcheck RUNTESTFLAGS="$(RUNTESTFLAGS)"
rpm: systemtap.spec dist
rpmbuild --define "_sourcedir $(PWD)/" -ba $(srcdir)/systemtap.spec
diff --git a/aclocal.m4 b/aclocal.m4
index 0e2027cd..9d70920d 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1,7 +1,7 @@
-# generated automatically by aclocal 1.10.1 -*- Autoconf -*-
+# generated automatically by aclocal 1.10 -*- Autoconf -*-
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-# 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# 2005, 2006 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@@ -11,15 +11,12 @@
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
-m4_ifndef([AC_AUTOCONF_VERSION],
- [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
-m4_if(AC_AUTOCONF_VERSION, [2.61],,
-[m4_warning([this file was generated for autoconf 2.61.
-You have another version of autoconf. It may work, but is not guaranteed to.
-If you have problems, you may need to regenerate the build system entirely.
-To do so, use the procedure documented by the package, typically `autoreconf'.])])
+m4_if(m4_PACKAGE_VERSION, [2.61],,
+[m4_fatal([this file was generated for autoconf 2.61.
+You have another version of autoconf. If you want to use that,
+you should regenerate the build system entirely.], [63])])
-# Copyright (C) 2002, 2003, 2005, 2006, 2007 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -34,7 +31,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION],
[am__api_version='1.10'
dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
dnl require some minimum version. Point them to the right macro.
-m4_if([$1], [1.10.1], [],
+m4_if([$1], [1.10], [],
[AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
])
@@ -50,10 +47,8 @@ m4_define([_AM_AUTOCONF_VERSION], [])
# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
# This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
-[AM_AUTOMAKE_VERSION([1.10.1])dnl
-m4_ifndef([AC_AUTOCONF_VERSION],
- [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
-_AM_AUTOCONF_VERSION(AC_AUTOCONF_VERSION)])
+[AM_AUTOMAKE_VERSION([1.10])dnl
+_AM_AUTOCONF_VERSION(m4_PACKAGE_VERSION)])
# AM_AUX_DIR_EXPAND -*- Autoconf -*-
@@ -348,7 +343,7 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
# each Makefile.in and add a new line on top of each file to say so.
# Grep'ing the whole file is not good either: AIX grep has a line
# limit of 2048, but all sed's we know have understand at least 4000.
- if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
+ if sed 10q "$mf" | grep '^#.*generated by automake' > /dev/null 2>&1; then
dirpart=`AS_DIRNAME("$mf")`
else
continue
@@ -396,13 +391,13 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
# Do all the work for Automake. -*- Autoconf -*-
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-# 2005, 2006, 2008 Free Software Foundation, Inc.
+# 2005, 2006 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
-# serial 13
+# serial 12
# This macro actually does too much. Some checks are only needed if
# your package does certain things. But this isn't really a big deal.
@@ -507,17 +502,16 @@ AC_PROVIDE_IFELSE([AC_PROG_OBJC],
# our stamp files there.
AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
[# Compute $1's index in $config_headers.
-_am_arg=$1
_am_stamp_count=1
for _am_header in $config_headers :; do
case $_am_header in
- $_am_arg | $_am_arg:* )
+ $1 | $1:* )
break ;;
* )
_am_stamp_count=`expr $_am_stamp_count + 1` ;;
esac
done
-echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
+echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count])
# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
#
@@ -878,7 +872,7 @@ AC_SUBST([INSTALL_STRIP_PROGRAM])])
# _AM_SUBST_NOTMAKE(VARIABLE)
# ---------------------------
-# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
+# Prevent Automake from outputing VARIABLE = @VARIABLE@ in Makefile.in.
# This macro is traced by Automake.
AC_DEFUN([_AM_SUBST_NOTMAKE])
diff --git a/doc/Makefile.in b/doc/Makefile.in
index e01c5ebf..6464afc3 100644
--- a/doc/Makefile.in
+++ b/doc/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# Makefile.in generated by automake 1.10 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
diff --git a/stap-client b/stap-client
index 3fa397a7..f4ccb033 100755
--- a/stap-client
+++ b/stap-client
@@ -102,8 +102,10 @@ function parse_options {
script_file=$first_token
cmdline1="$cmdline2"
cmdline2=
- else
+ elif test "$first_char" != "'"; then
cmdline2="$cmdline2 '$first_token'"
+ else
+ cmdline2="$cmdline2 $first_token"
fi
advance_p=$(($advance_p + 1))
break
@@ -381,13 +383,15 @@ function package_request {
# client -> "request:"
# client -> $tar_client
function send_request {
- # Send the request file. We need to redirect to /dev/null
- # in order to workaround a nc bug. It closes the connection
- # early if stdin from the other side is not provided.
- until nc $server $(($port + 1)) < $tar_client > /dev/null
+ # Send the request file.
+ for ((attempt=0; $attempt < 10; ++attempt))
do
+ if nc -w10 $server $(($port+1)) < $tar_client > /dev/null 2>&1; then
+ return;
+ fi
sleep 1
done
+ fatal "ERROR: Unable to connect to server while sending request file"
}
# function: receive_response
@@ -398,13 +402,15 @@ function receive_response {
tar_server=`mktemp -t $tmpdir_prefix_client.server.tgz.XXXXXX` || \
fatal "ERROR: cannot create temporary file " $tar_server
- # Retrieve the file. We need to redirect stdin from /dev/zero to work
- # around a bug in nc. It closes the connection early is stdin is not
- # provided.
- until nc $server $(($port + 1)) < /dev/zero > $tar_server
+ # Retrieve the file. Wait for up to 5 minutes for a response.
+ for ((attempt=0; $attempt < 300; ++attempt))
do
+ if nc -d $server $(($port+1)) > $tar_server 2>/dev/null; then
+ return;
+ fi
sleep 1
done
+ fatal "ERROR: Unable to connect to server while receiving response file"
}
# function: unpack_response
@@ -516,8 +522,8 @@ function choose_server {
fi
done
- if test num_servers = 0; then
- fatal "ERROR: cannot find a server"
+ if test $num_servers = 0; then
+ fatal "ERROR: unable to find a server"
fi
fatal "ERROR: unable to connect to a server"
@@ -527,10 +533,15 @@ function choose_server {
#
# Establish connection with the given server
function connect_to_server {
- until echo "request:" | nc $1 $2 > /dev/null
+ for ((attempt=0; $attempt < 10; ++attempt))
do
+ if echo "request:" | nc -w10 $1 $2 >/dev/null 2>&1; then
+ return 0
+ fi
sleep 1
done
+
+ return 1
}
# function: disconnect_from_server
diff --git a/stap-server b/stap-server
index b82bc695..67573de7 100755
--- a/stap-server
+++ b/stap-server
@@ -47,29 +47,26 @@ function initialization {
# function: receive_request
#
# Receive a tar file representing the request from the client:
-# The protocol is:
-# client -> "request:"
-# client -> $tar_client
function receive_request {
- # Request from the client is on stdin
- read
- line=$REPLY
-
- # Check to see that it is a client request
- test "$line" = "request:" || \
- fatal "ERROR: client request, '$line' is incorrect"
-
# Create a place to receive the client's tar file
tar_client=`mktemp -t $tmpdir_prefix_server.client.tgz.XXXXXX` || \
fatal "ERROR: cannot create temporary tar file " $tar_client
- # Receive the file. We need to redirect stdin from /dev/zero to work
- # around a bug in nc. It closes the connection early is stdin is not
- # provided.
- nc -l $port < /dev/zero > $tar_client &
+ # Receive the file.
+ nc -ld $port > $tar_client 2>/dev/null &
+
+ # Wait for 10 seconds before timing out
+ for ((t=0; $t < 10; ++t))
+ do
+ if jobs '%nc -l' >/dev/null 2>&1; then
+ sleep 1
+ else
+ return
+ fi
+ done
- # Wait for the transfer to complete.
- wait '%nc' >/dev/null 2>&1
+ # We have timed out. fatal will kill the job.
+ fatal "Timed out waiting for client request file"
}
# function: unpack_request
@@ -386,11 +383,21 @@ function package_response {
#
# Wait for the client to take the response file.
function send_response {
- # Now send it. We need to redirect to /dev/null
- # in order to workaround a nc bug. It closes the connection
- # early if stdin from the other side is not provided.
- nc -l $port < $tar_server > /dev/null &
- wait '%nc' >/dev/null 2>&1
+ # Now send it.
+ nc -l $port < $tar_server > /dev/null 2>&1 &
+
+ # Wait for 10 seconds before timing out
+ for ((t=0; $t < 10; ++t))
+ do
+ if jobs '%nc -l' >/dev/null 2>&1; then
+ sleep 1
+ else
+ return
+ fi
+ done
+
+ # We have timed out. fatal will kill the job.
+ fatal "Timed out waiting to send response file"
}
# function: fatal [ MESSAGE ]
diff --git a/stap-serverd b/stap-serverd
index 6970217d..45aacf63 100755
--- a/stap-serverd
+++ b/stap-serverd
@@ -22,11 +22,10 @@ trap 'terminate' SIGTERM SIGINT
# function: initialization PORT
function initialization {
# Default settings.
- tmpdir_prefix_serverd=stap.serverd
avahi_type=_stap._tcp
port=$1
test "X$port" = "X" && port=65000
- port2=$(($port + 1))
+ export port2=$(($port + 1))
if netstat -atn | awk '{print $4}' | cut -f2 -d: | egrep -q "^($port|$port2)\$"; then
# Whoops, the port is busy; try another one.
initialization $((1024+($port + $RANDOM)%64000))
@@ -53,43 +52,41 @@ function advertise_presence {
#
# Listen for and handle requests to the server.
function listen {
- # Work in a temporary directory
- tmpdir=`mktemp -dt $tmpdir_prefix_serverd.XXXXXX` || \
- fatal "ERROR: cannot create temporary directory " $tmpdir
- cd $tmpdir
-
- # Create a fifo for communicating with the server
- local fifo_name=$tmpdir_prefix_serverd.fifo
- mknod $fifo_name p || \
- fatal "ERROR: cannot create temporary fifo " $tmpdir/$fifo_name
-
# 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.
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' >/dev/null 2>&1
+ nc -ld $port 2>/dev/null | process_request &
+ wait '%nc -l'
rc=$?
- if test $rc = 127 -o $rc = 0; then
- break; # success
+ if test $rc = 0 -o $rc = 127; then
+ break; # port was read ok
fi
- sleep 1
done
if test $attempt = 5; then
fatal "ERROR: cannot listen on port $port. rc==$rc"
fi
done
- set +o pipefail # restore
+}
+
+# function: process_request
+#
+# Process an incoming request on stdin
+function process_request {
+ read
+ case $REPLY in
+ request:)
+ stap-server $port2 >/dev/null 2>&1 &
+ wait '%stap-server'
+ rc=$?
+ test $rc = 127 && rc=0
+ ;;
+ *)
+ rc=1
+ esac
+
+ exit $rc
}
# function: fatal [ MESSAGE ]
@@ -112,13 +109,13 @@ function terminate {
kill -s SIGTERM %avahi-publish-service 2> /dev/null
wait '%avahi-publish-service' >/dev/null 2>&1
- # Kill any running 'nc -l' job.
- kill -s SIGTERM "%nc -l" 2> /dev/null
- wait "%nc - l" >/dev/null 2>&1
+ # Kill any running 'stap-server' job.
+ kill -s SIGTERM "%stap-server" 2> /dev/null
+ wait "%stap-server" >/dev/null 2>&1
- # Clean up
- cd `dirname $tmpdir`
- rm -fr $tmpdir
+ # Kill any running 'nc -l' job.
+ kill -s SIGTERM "%?nc -l" 2> /dev/null
+ wait "%?nc - l" >/dev/null 2>&1
exit
}
@@ -127,4 +124,5 @@ function terminate {
# Beginning of main line execution.
#-----------------------------------------------------------------------------
initialization "$@"
+advertise_presence
listen
diff --git a/testsuite/Makefile.in b/testsuite/Makefile.in
index 9c708bc9..f3b56f6f 100644
--- a/testsuite/Makefile.in
+++ b/testsuite/Makefile.in
@@ -140,7 +140,13 @@ EXTRA_DIST = execrc config lib systemtap \
parseok parseko semok semko transok transko buildok buildok \
systemtap.syscall systemtap.stress systemtap.string \
systemtap.pass1-4 systemtap.samples systemtap.printf \
- systemtap.maps systemtap.base
+ systemtap.maps systemtap.base \
+ systemtap.examples/examples-index-gen.pl \
+ systemtap.examples/systemtap.css \
+ systemtap.examples/systemtapcorner.gif \
+ systemtap.examples/systemtaplogo.png \
+ systemtap.examples/html_footer.tmpl \
+ systemtap.examples/html_header.tmpl
# $(srcdir)/These values point the test suite to the install tree, and