Blame SOURCES/rhbz1035752.patch

f43afa
From 735972b4c681efeff3c4137816cb913174a839be Mon Sep 17 00:00:00 2001
f43afa
From: Jonathan Lebon <jlebon@redhat.com>
f43afa
Date: Mon, 2 Dec 2013 11:17:05 -0500
f43afa
Subject: [PATCH 1/2] Resolves: #1035752
f43afa
f43afa
Upstream commit e7d52b3.
f43afa
---
f43afa
 csclient.cxx     |  2 +-
f43afa
 stap-serverd.cxx | 34 ++++++++++++++++++----------------
f43afa
 2 files changed, 19 insertions(+), 17 deletions(-)
f43afa
f43afa
diff --git a/csclient.cxx b/csclient.cxx
f43afa
index cce5428..4cfeb08 100644
f43afa
--- a/csclient.cxx
f43afa
+++ b/csclient.cxx
f43afa
@@ -829,7 +829,7 @@ compile_server_client::passes_0_4 ()
f43afa
            << TIMESPRINT
f43afa
            << endl;
f43afa
     }
f43afa
-  if (rc)
f43afa
+  if (rc && !s.listing_mode)
f43afa
     {
f43afa
       clog << _("Passes: via server failed.  Try again with another '-v' option.") << endl;
f43afa
     }
f43afa
diff --git a/stap-serverd.cxx b/stap-serverd.cxx
f43afa
index 53a8d3a..035d06c 100644
f43afa
--- a/stap-serverd.cxx
f43afa
+++ b/stap-serverd.cxx
f43afa
@@ -63,7 +63,7 @@ extern "C" {
f43afa
 using namespace std;
f43afa
 
f43afa
 static void cleanup ();
f43afa
-static PRStatus spawn_and_wait (const vector<string> &argv,
f43afa
+static PRStatus spawn_and_wait (const vector<string> &argv, int *result,
f43afa
                                 const char* fd0, const char* fd1, const char* fd2,
f43afa
 				const char *pwd, const vector<string>& envVec = vector<string> ());
f43afa
 
f43afa
@@ -1234,18 +1234,19 @@ handleRequest (const string &requestDirName, const string &responseDirName, stri
f43afa
   get_stap_locale (staplang, envVec, stapstderr, &client_version);
f43afa
 
f43afa
   /* All ready, let's run the translator! */
f43afa
-  rc = spawn_and_wait(stapargv, "/dev/null", stapstdout.c_str (), stapstderr.c_str (),
f43afa
-		      requestDirName.c_str (), envVec);
f43afa
+  int staprc;
f43afa
+  rc = spawn_and_wait(stapargv, &staprc, "/dev/null", stapstdout.c_str (),
f43afa
+                      stapstderr.c_str (), requestDirName.c_str (), envVec);
f43afa
+  if (rc != PR_SUCCESS)
f43afa
+    {
f43afa
+      server_error(_("Failed spawning translator"));
f43afa
+      return;
f43afa
+    }
f43afa
 
f43afa
   /* Save the RC */
f43afa
-  string staprc = responseDirName + "/rc";
f43afa
-  f = fopen(staprc.c_str (), "w");
f43afa
-  if (f) 
f43afa
-    {
f43afa
-      /* best effort basis */
f43afa
-      fprintf(f, "%d", rc);
f43afa
-      fclose(f);
f43afa
-    }
f43afa
+  ofstream ofs((responseDirName + "/rc").c_str());
f43afa
+  ofs << staprc;
f43afa
+  ofs.close();
f43afa
 
f43afa
   // In unprivileged modes, if we have a module built, we need to sign the sucker.
f43afa
   privilege_t privilege = getRequestedPrivilege (stapargv);
f43afa
@@ -1316,7 +1317,7 @@ handleRequest (const string &requestDirName, const string &responseDirName, stri
f43afa
 /* A front end for stap_spawn that handles stdin, stdout, stderr, switches to a working
f43afa
    directory and returns overall success or failure. */
f43afa
 static PRStatus
f43afa
-spawn_and_wait (const vector<string> &argv,
f43afa
+spawn_and_wait (const vector<string> &argv, int *spawnrc,
f43afa
 		const char* fd0, const char* fd1, const char* fd2,
f43afa
 		const char *pwd, const vector<string>& envVec)
f43afa
 { 
f43afa
@@ -1380,8 +1381,8 @@ spawn_and_wait (const vector<string> &argv,
f43afa
       return PR_FAILURE;
f43afa
     }
f43afa
 
f43afa
-  rc = stap_waitpid (0, pid);
f43afa
-  if (rc == -1)
f43afa
+  *spawnrc = stap_waitpid (0, pid);
f43afa
+  if (*spawnrc == -1)
f43afa
     {
f43afa
       server_error (_("Error in waitpid"));
f43afa
       return PR_FAILURE;
f43afa
@@ -1540,14 +1541,15 @@ handle_connection (void *arg)
f43afa
   handleRequest(requestDirName, responseDirName, stapstderr);
f43afa
 
f43afa
   /* Zip the response. */
f43afa
+  int ziprc;
f43afa
   argv.clear ();
f43afa
   argv.push_back ("zip");
f43afa
   argv.push_back ("-q");
f43afa
   argv.push_back ("-r");
f43afa
   argv.push_back (responseFileName);
f43afa
   argv.push_back (".");
f43afa
-  rc = spawn_and_wait (argv, NULL, NULL, NULL, responseDirName);
f43afa
-  if (rc != PR_SUCCESS)
f43afa
+  rc = spawn_and_wait (argv, &ziprc, NULL, NULL, NULL, responseDirName);
f43afa
+  if (rc != PR_SUCCESS || ziprc != 0)
f43afa
     {
f43afa
       server_error (_("Unable to compress server response"));
f43afa
       goto cleanup;
f43afa
-- 
f43afa
1.8.3.1
f43afa