diff options
author | tradke <tradke@83718e91-0e4f-0410-abf4-91180603181f> | 2006-07-17 11:39:25 +0000 |
---|---|---|
committer | tradke <tradke@83718e91-0e4f-0410-abf4-91180603181f> | 2006-07-17 11:39:25 +0000 |
commit | fc3c59e8dad9476c97d58dd89024f222abaa76bd (patch) | |
tree | bc9b5e4f921e69f99f4e92005826d06bb8794814 /src/rdf.cc | |
parent | d2ed4186f47122d1e48330d53d421ba49b510971 (diff) |
Include all socket operations in the timeout given by Formaline::timeout.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusUtils/Formaline/trunk@100 83718e91-0e4f-0410-abf4-91180603181f
Diffstat (limited to 'src/rdf.cc')
-rw-r--r-- | src/rdf.cc | 45 |
1 files changed, 22 insertions, 23 deletions
@@ -418,37 +418,36 @@ namespace Formaline << " my $host = $1;" << endl << " my $port = $2;" << endl << endl -<< " my $iaddr = inet_aton ($host);" << endl -<< " next if (not $iaddr);" << endl -<< " my $sin = sockaddr_in ($port, $iaddr);" << endl -<< " socket (my $SH, PF_INET, SOCK_STREAM, getprotobyname ('tcp'));" << endl -<< " next if (not defined $SH);" << endl -<< endl << " # set a timeout for the entire interaction with this server" << endl << " eval {" << endl << " local $SIG{ALRM} = sub { die 'timeout' };" << endl << " alarm " << timeout << ";" << endl << endl +<< " my $iaddr = inet_aton ($host);" << endl +<< " die \"Couldn't get IP address for '$host'\" if (not $iaddr);" << endl +<< " my $sin = sockaddr_in ($port, $iaddr);" << endl +<< " socket (my $SH, PF_INET, SOCK_STREAM, getprotobyname ('tcp'));" << endl +<< " die 'Couldn\\'t open TCP socket' if (not defined $SH);" << endl +<< endl << " # connect and send off the data" << endl -<< " if (connect ($SH, $sin)) {" << endl +<< " die \"Couldn't connect to '$host:$port'\" if ! connect ($SH, $sin);" << endl // currently the RDF server only understands HTTP PUT // << "POST HTTP/1.0 200\r\n" -<< " my $header = \"PUT /context/CactusSimulations/" << jobID << " HTTP/1.0\\r\\n\" ." << endl -<< " \"Host: $entry\\r\\n\" ." << endl -<< " \"Content-Type: application/rdf+xml\\r\\n\" ." << endl -<< " \"Content-Length: " << msgstr.length() << "\\r\\n\" ." << endl -<< " \"\\r\\n\";" << endl -<< " my $footer = \"\\r\\n\\r\\n\";" << endl +<< " my $header = \"PUT /context/CactusSimulations/" << jobID << " HTTP/1.0\\r\\n\" ." << endl +<< " \"Host: $entry\\r\\n\" ." << endl +<< " \"Content-Type: application/rdf+xml\\r\\n\" ." << endl +<< " \"Content-Length: " << msgstr.length() << "\\r\\n\" ." << endl +<< " \"\\r\\n\";" << endl +<< " my $footer = \"\\r\\n\\r\\n\";" << endl << endl -<< " open (my $FH, '<' . $input);" << endl -<< " print $SH $header;" << endl -<< " print $SH $_ while (<$FH>);" << endl -<< " print $SH $footer;" << endl -<< " # print $_ while (<$SH>);" << endl -<< " close $FH;" << endl -<< " }" << endl +<< " open (my $FH, '<' . $input);" << endl +<< " print $SH $header;" << endl +<< " print $SH $_ while (<$FH>);" << endl +<< " print $SH $footer;" << endl +<< " # print $_ while (<$SH>);" << endl +<< " close $FH;" << endl +<< " close $SH;" << endl << " };" << endl -<< " close $SH;" << endl << "}" << endl << endl; string const scriptstr = scriptbuf.str(); @@ -617,8 +616,8 @@ namespace Formaline } } - remove (datafilename); - remove (scriptfilename); +// remove (datafilename); +// remove (scriptfilename); } |