diff options
author | Dave Brolley <brolley@redhat.com> | 2008-08-25 11:23:41 -0400 |
---|---|---|
committer | Dave Brolley <brolley@redhat.com> | 2008-08-25 11:23:41 -0400 |
commit | b593551607cc5b6ef512e787b0f881d99c4ac6c5 (patch) | |
tree | 67837d35b794a76a3d5d3cabfdeb3deac71a12d0 /stap-server | |
parent | 4550733ebf24fb067f9a2350e0ab86d44fea932e (diff) | |
download | systemtap-steved-b593551607cc5b6ef512e787b0f881d99c4ac6c5.tar.gz systemtap-steved-b593551607cc5b6ef512e787b0f881d99c4ac6c5.tar.xz systemtap-steved-b593551607cc5b6ef512e787b0f881d99c4ac6c5.zip |
Robustness improvements for the stap client/server
Diffstat (limited to 'stap-server')
-rwxr-xr-x | stap-server | 51 |
1 files changed, 29 insertions, 22 deletions
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 ] |