Skip to content

Commit

Permalink
Revert "fixed excessive spawning of child processes / fixed potential…
Browse files Browse the repository at this point in the history
… zombie processes (danmar#2924)"

This reverts commit 873aa07.

There was performance issues.
  • Loading branch information
danmar committed Dec 3, 2020
1 parent 904d52a commit 5650897
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 33 deletions.
43 changes: 16 additions & 27 deletions cli/threadexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ unsigned int ThreadExecutor::check()
std::list<ImportProject::FileSettings>::const_iterator iFileSettings = mSettings.project.fileSettings.begin();
for (;;) {
// Start a new child
size_t nchildren = childFile.size();
size_t nchildren = rpipes.size();
if ((iFile != mFiles.end() || iFileSettings != mSettings.project.fileSettings.end()) && nchildren < mSettings.jobs && checkLoadAverage(nchildren)) {
int pipes[2];
if (pipe(pipes) == -1) {
Expand Down Expand Up @@ -284,7 +284,7 @@ unsigned int ThreadExecutor::check()
++rp;
}
}
} else if (!childFile.empty()) {

int stat = 0;
pid_t child = waitpid(0, &stat, WNOHANG);
if (child > 0) {
Expand All @@ -295,17 +295,21 @@ unsigned int ThreadExecutor::check()
childFile.erase(c);
}

if (WIFEXITED(stat)) {
const int exitstaus = WEXITSTATUS(stat);
if (exitstaus != 0) {
std::ostringstream oss;
oss << "Child process exited with " << exitstaus;
reportInternalChildErr(childname, oss.str());
}
} else if (WIFSIGNALED(stat)) {
if (WIFSIGNALED(stat)) {
std::ostringstream oss;
oss << "Child process crashed with signal " << WTERMSIG(stat);
reportInternalChildErr(childname, oss.str());
oss << "Internal error: Child process crashed with signal " << WTERMSIG(stat);

std::list<ErrorMessage::FileLocation> locations;
locations.emplace_back(childname, 0, 0);
const ErrorMessage errmsg(locations,
emptyString,
Severity::error,
oss.str(),
"cppcheckError",
false);

if (!mSettings.nomsg.isSuppressed(errmsg.toSuppressionsErrorMessage()))
mErrorLogger.reportErr(errmsg);
}
}
} else {
Expand Down Expand Up @@ -355,21 +359,6 @@ void ThreadExecutor::bughuntingReport(const std::string &str)
writeToPipe(REPORT_VERIFICATION, str.c_str());
}

void ThreadExecutor::reportInternalChildErr(const std::string &childname, const std::string &msg)
{
std::list<ErrorMessage::FileLocation> locations;
locations.emplace_back(childname, 0, 0);
const ErrorMessage errmsg(locations,
emptyString,
Severity::error,
"Internal error: " + msg,
"cppcheckError",
false);

if (!mSettings.nomsg.isSuppressed(errmsg.toSuppressionsErrorMessage()))
mErrorLogger.reportErr(errmsg);
}

#elif defined(THREADING_MODEL_WIN)

void ThreadExecutor::addFileContent(const std::string &path, const std::string &content)
Expand Down
6 changes: 0 additions & 6 deletions cli/threadexecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,6 @@ class ThreadExecutor : public ErrorLogger {
*/
bool checkLoadAverage(size_t nchildren);

/**
* @brief Reports internal errors related to child processes
* @param msg The error message
*/
void reportInternalChildErr(const std::string &childname, const std::string &msg);

public:
/**
* @return true if support for threads exist.
Expand Down

0 comments on commit 5650897

Please sign in to comment.