summaryrefslogtreecommitdiff
path: root/cpu_ref/rsCpuScriptGroup2.cpp
diff options
context:
space:
mode:
authorPirama Arumuga Nainar <pirama@google.com>2015-03-25 17:21:40 -0700
committerPirama Arumuga Nainar <pirama@google.com>2015-03-25 18:16:26 -0700
commit2fa8a238dd69afebdeb757adcb1d674043d78e32 (patch)
tree4251f971d9e9bbf07587500830050ba8a78660a1 /cpu_ref/rsCpuScriptGroup2.cpp
parentbe8c89541d8b094d4a01a5539dac738003bf36cc (diff)
downloadrs-2fa8a238dd69afebdeb757adcb1d674043d78e32.tar.gz
Wrap TEMP_FAILURE_RETRY around system calls
BUG 19934827 Wrap TEMP_FAILURE_RETRY around system calls that can return EINTR (waitpid, close). Refactor fork/exec flows in various places into a utility function and log errors so we can better understand failures in the test server. Fix a small use-after-free issue in ScriptGroups. Change-Id: I60b192f83c395a13c27cd6bd2289c44132b84791
Diffstat (limited to 'cpu_ref/rsCpuScriptGroup2.cpp')
-rw-r--r--cpu_ref/rsCpuScriptGroup2.cpp46
1 files changed, 6 insertions, 40 deletions
diff --git a/cpu_ref/rsCpuScriptGroup2.cpp b/cpu_ref/rsCpuScriptGroup2.cpp
index 2e50ecb9..3a50221c 100644
--- a/cpu_ref/rsCpuScriptGroup2.cpp
+++ b/cpu_ref/rsCpuScriptGroup2.cpp
@@ -12,7 +12,6 @@
#ifndef RS_COMPATIBILITY_LIB
#include "bcc/Config/Config.h"
-#include <sys/wait.h>
#endif
#include "cpu_ref/rsCpuCore.h"
@@ -264,40 +263,6 @@ void setupCompileArguments(
args->push_back(nullptr);
}
-bool fuseAndCompile(const char** arguments,
- const string& commandLine) {
- const pid_t pid = fork();
-
- if (pid == -1) {
- ALOGE("Couldn't fork for bcc execution");
- return false;
- }
-
- if (pid == 0) {
- // Child process
- ALOGV("Invoking BCC with: %s", commandLine.c_str());
- execv(RsdCpuScriptImpl::BCC_EXE_PATH, (char* const*)arguments);
-
- ALOGE("execv() failed: %s", strerror(errno));
- abort();
- return false;
- }
-
- // Parent process
- int status = 0;
- const pid_t w = waitpid(pid, &status, 0);
- if (w == -1) {
- return false;
- }
-
- if (!WIFEXITED(status) || WEXITSTATUS(status) != 0 ) {
- ALOGE("bcc terminated unexpectedly");
- return false;
- }
-
- return true;
-}
-
void generateSourceSlot(const Closure& closure,
const std::vector<std::string>& inputs,
std::stringstream& ss) {
@@ -384,13 +349,14 @@ void CpuScriptGroup2Impl::compile(const char* cacheDir) {
const string& coreLibPath = getCoreLibPath(getCpuRefImpl()->getContext(),
&coreLibRelaxedPath);
vector<const char*> arguments;
- setupCompileArguments(inputs, kernelBatches, invokeBatches, cacheDir,
+ string output_dir(cacheDir);
+ setupCompileArguments(inputs, kernelBatches, invokeBatches, output_dir,
outputFileName, coreLibPath, coreLibRelaxedPath, &arguments);
- std::unique_ptr<const char> joined(
- rsuJoinStrings(arguments.size() - 1, arguments.data()));
- string commandLine (joined.get());
- if (!fuseAndCompile(arguments.data(), commandLine)) {
+ bool compiled = rsuExecuteCommand(RsdCpuScriptImpl::BCC_EXE_PATH,
+ arguments.size()-1,
+ arguments.data());
+ if (!compiled) {
unlink(objFilePath.c_str());
return;
}