NightlyTest: Write "sentdata.txt" files and run the -submit-aux script before
authorDaniel Dunbar <daniel@zuster.org>
Thu, 28 May 2009 18:31:40 +0000 (18:31 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Thu, 28 May 2009 18:31:40 +0000 (18:31 +0000)
sending data to the server.
 - Otherwise if the server connection fails the external script never runs.

Also, create content before initiating connection to try and decrease time we
are connected to llvm.org.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72532 91177308-0d34-0410-b5e6-96231b3b80d8

utils/NewNightlyTest.pl

index dc6cf6d17f5251d93e0c0aa5ecfc84b7e59b80ed..6837dc0e7291804ece5f50bde952f233459c848b 100755 (executable)
@@ -445,14 +445,21 @@ sub SendData{
     $file = $_[1];
     $variables=$_[2];
 
-    $port=80;
-    $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
-    socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or
-      die "Bad socket\n";
-    connect SOCK, $socketaddr or die "Bad connection\n";
-    select((select(SOCK), $| = 1)[0]);
+    # Write out the "...-sentdata.txt" file.
+
+    my $sentdata="";
+    foreach $x (keys (%$variables)){
+        $value = $variables->{$x};
+        $sentdata.= "$x  => $value\n";
+    }
+    WriteFile "$Prefix-sentdata.txt", $sentdata;
+
+    if (!($SUBMITAUX eq "")) {
+      system "$SUBMITAUX \"$Prefix-sentdata.txt\"";
+    }
+
+    # Create the content to send to the server.
 
-    #creating content here
     my $content;
     foreach $key (keys (%$variables)){
         $value = $variables->{$key};
@@ -460,6 +467,17 @@ sub SendData{
         $content .= "$key=$value&";
     }
 
+    # Send the data to the server.
+    # 
+    # FIXME: This code should be more robust?
+    
+    $port=80;
+    $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
+    socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or
+      die "Bad socket\n";
+    connect SOCK, $socketaddr or die "Bad connection\n";
+    select((select(SOCK), $| = 1)[0]);
+
     $length = length($content);
 
     my $send= "POST $file HTTP/1.0\n";
@@ -475,17 +493,6 @@ sub SendData{
     }
     close(SOCK);
 
-    my $sentdata="";
-    foreach $x (keys (%$variables)){
-        $value = $variables->{$x};
-        $sentdata.= "$x  => $value\n";
-    }
-    WriteFile "$Prefix-sentdata.txt", $sentdata;
-
-    if (!($SUBMITAUX eq "")) {
-      system "$SUBMITAUX \"$Prefix-sentdata.txt\"";
-    }
-
     return $result;
 }