diff options
author | schnetter <schnetter@83718e91-0e4f-0410-abf4-91180603181f> | 2007-05-24 01:58:48 +0000 |
---|---|---|
committer | schnetter <schnetter@83718e91-0e4f-0410-abf4-91180603181f> | 2007-05-24 01:58:48 +0000 |
commit | ebb0ea37efad78e01d71afc40e39e36f402aa75e (patch) | |
tree | 370bbbade924e4ddb5a6d96f67c8912215f55f5a /src/senddata.cc | |
parent | 2b19e0d432ebb3f026c8847a24f79b44119f930f (diff) |
Output host name and port number when communication fails.
Output details not only for the first failure, but for the first
failure for each host name/port number combination.
Do not forward DISPLAY when using ssh tunnels.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusUtils/Formaline/trunk@120 83718e91-0e4f-0410-abf4-91180603181f
Diffstat (limited to 'src/senddata.cc')
-rw-r--r-- | src/senddata.cc | 48 |
1 files changed, 34 insertions, 14 deletions
diff --git a/src/senddata.cc b/src/senddata.cc index 1d40e21..4219608 100644 --- a/src/senddata.cc +++ b/src/senddata.cc @@ -3,6 +3,7 @@ #include <cstring> #include <fstream> #include <list> +#include <set> #include <sstream> #include <string> @@ -35,6 +36,18 @@ namespace Formaline { DECLARE_CCTK_PARAMETERS; +#if 0 + // pair<,> is not a standard STL class + typedef pair <string, int> destination_t; + destination_t const destination (hostname, port); +#endif + typedef string destination_t; + ostringstream dest_buffer; + dest_buffer << hostname << ":" << port; + destination_t const destination = dest_buffer.str(); + + + string const socket_script = "socket-client.pl"; string const socket_data = "socket-data"; @@ -122,7 +135,7 @@ namespace Formaline // Make the script executable ostringstream chmodbuf; chmodbuf << "/bin/sh -c 'chmod a+x " << scriptfilenamestr - << " < /dev/null > /dev/null 2> /dev/null'"; + << " < /dev/null'"; string const chmodstr = chmodbuf.str(); char const * const chmod = chmodstr.c_str(); system (chmod); @@ -171,11 +184,15 @@ namespace Formaline if (my_use_relay_host) { CCTK_VInfo (CCTK_THORNSTRING, - "Using \"%s\" as relay host", my_relay_host); + "Using %s as relay host to announce to %s:%d", + my_relay_host, + hostname.c_str(), port); } else { - CCTK_INFO ("Announcing without relay host"); + CCTK_VInfo (CCTK_THORNSTRING, + "Announcing to %s:%d without relay host", + hostname.c_str(), port); } } } @@ -186,11 +203,14 @@ namespace Formaline // Check that the relay host name is sane if (! is_clean_for_shell (my_relay_host)) { - static bool did_complain = false; - if (! did_complain) + static set <destination_t> did_complain; + if (did_complain.count(destination) == 0) { - did_complain = true; - CCTK_WARN (1, "Strange character in relay host name -- not calling system()"); + did_complain.insert (destination); + CCTK_VWarn (CCTK_WARN_ALERT, + __LINE__, __FILE__, CCTK_THORNSTRING, + "Strange character in relay host name \"%s\" -- not calling system()", + hostname.c_str()); return -2; } } @@ -237,13 +257,11 @@ namespace Formaline ostringstream cmdbuf; if (my_use_relay_host) { - cmdbuf << "ssh -x " << my_relay_host << " \"/bin/sh -c '" + cmdbuf << "env DISPLAY= ssh -x " << my_relay_host << " \"/bin/sh -c '" << "cd " << cwd << " && "; } else { cmdbuf << "/bin/sh -c '"; } - // Do not hide stdout and stderr of the script - // cmdbuf << scriptfilenamestr << " < /dev/null > /dev/null 2> /dev/null'"; cmdbuf << scriptfilenamestr << " < /dev/null'"; if (my_use_relay_host) { @@ -262,11 +280,13 @@ namespace Formaline raise (SIGINT); } - static bool did_complain = false; - if (! did_complain) + static set <destination_t> did_complain; + if (did_complain.count(destination) == 0) { - did_complain = true; - CCTK_WARN (1, "Failed to send data"); + did_complain.insert (destination); + CCTK_VWarn (CCTK_WARN_ALERT, + __LINE__, __FILE__, CCTK_THORNSTRING, + "Failed to send data to %s:%d", hostname.c_str(), port); return -5; } } |