diff options
author | Frank Ch. Eigler <fche@elastic.org> | 2008-07-04 17:11:29 -0400 |
---|---|---|
committer | Frank Ch. Eigler <fche@elastic.org> | 2008-07-04 17:11:29 -0400 |
commit | 53f7dd30e87fa480c5d43ce2a1312ce27a4372c9 (patch) | |
tree | 4f1c64048d43c50c11877a66d3f7f918e43a0f7b /stap-serverd | |
parent | 1b94bf6d310cf41041d0a6c24be85a892d443708 (diff) | |
parent | 422b0781177e0755df5542e1c70e809e6f3cfe89 (diff) | |
download | systemtap-steved-53f7dd30e87fa480c5d43ce2a1312ce27a4372c9.tar.gz systemtap-steved-53f7dd30e87fa480c5d43ce2a1312ce27a4372c9.tar.xz systemtap-steved-53f7dd30e87fa480c5d43ce2a1312ce27a4372c9.zip |
Merge commit 'origin/master' into pr6429-comp-unwindsyms
* commit 'origin/master':
ubuntu (2.6.24-16-server) kernel compatibility fix
client/server take 2. See bz6565.
Add functioncallcount.meta and functioncallcount.stp.
Add para-callgraph.stp and para-callgraph.meta.
Fixed __stp_get_mm_path() error return code.
diagnostics improvement: print arch/mach at top if -vv
Make _vfs.generic_commit_write only for kernel<=2.6.25
Handles "mortally wounded" threads correctly when detaching.
further clarify that elfutils need not be absolutely freshest, nor rebuilt every time
point out releases/ directory; clarify optionality of elfutils bundling
Add auto_free_ref to auto_free stuff; bug 6694
Diffstat (limited to 'stap-serverd')
-rwxr-xr-x | stap-serverd | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/stap-serverd b/stap-serverd new file mode 100755 index 00000000..2c0743c0 --- /dev/null +++ b/stap-serverd @@ -0,0 +1,93 @@ +#!/bin/bash + +# Compile server manager for systemtap +# +# Copyright (C) 2008 Red Hat Inc. +# +# This file is part of systemtap, and is free software. You can +# redistribute it and/or modify it under the terms of the GNU General +# Public License (GPL); either version 2, or (at your option) any +# later version. + +# This script publishes its presence on the network and then listens for +# incoming connections. When a connection is detected, the stap-server script +# is run to handle the request. + +# Catch ctrl-c +trap 'handle_sigint' SIGINT + +#----------------------------------------------------------------------------- +# Helper functions. +#----------------------------------------------------------------------------- +# function: initialization PORT +function initialization { + # Default settings. + tmpdir_prefix_serverd=stap.serverd + avahi_type=_stap._tcp + port=$1 + test "X$port" = "X" && port=65000 +} + +# function: advertise_presence +# +# Advertise the availability of the server on the network. +function advertise_presence { + # Build up a string representing our server's properties. + # TODO: this needs fleshing out. + + local sysinfo=`uname -r` + local txt="$sysinfo" + + # Call avahi-publish-service to advertise our presence. + avahi-publish-service "Systemtap Compile Server on `uname -n`" \ + $avahi_type $port $txt > /dev/null 2>&1 & + + echo "Systemtap Compile Server on `uname -n` listening on port $port" +} + +# function: listen +# +# 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 + while true + do + nc -l $port < $fifo_name | stap-server $((port + 1)) > $fifo_name 2>&1 + done +} + +# function: fatal [ MESSAGE ] +# +# Fatal error +# Prints its arguments to stderr and exits +function fatal { + echo "$@" >&2 + exit 1 +} + +# function: handle_sigint +# +# Terminate gracefully when SIGINT is received. +function handle_sigint { + echo "$0: received SIGINT. Exiting." + cd `dirname $tmpdir` + rm -fr $tmpdir + exit +} + +#----------------------------------------------------------------------------- +# Beginning of main line execution. +#----------------------------------------------------------------------------- +initialization "$@" +advertise_presence +listen |