Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removed unused ErrorLogger::reportInfo() / small *Executor cleanup #4852

Merged
merged 2 commits into from
Mar 4, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
small *Executor cleanup
  • Loading branch information
firewave committed Mar 4, 2023
commit 9eda395ab1216312119a1abbfa1bf985a2a87cb1
21 changes: 3 additions & 18 deletions cli/processexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,27 +77,14 @@ class PipeWriter : public ErrorLogger {
}

void reportErr(const ErrorMessage &msg) override {
report(msg, MessageType::REPORT_ERROR);
writeToPipe(REPORT_ERROR, msg.serialize());
}

void writeEnd(const std::string& str) const {
writeToPipe(CHILD_END, str);
}

private:
enum class MessageType {REPORT_ERROR};

void report(const ErrorMessage &msg, MessageType msgType) const {
PipeSignal pipeSignal;
switch (msgType) {
case MessageType::REPORT_ERROR:
pipeSignal = REPORT_ERROR;
break;
}

writeToPipe(pipeSignal, msg.serialize());
}

void writeToPipe(PipeSignal type, const std::string &data) const
{
unsigned int len = static_cast<unsigned int>(data.length() + 1);
Expand Down Expand Up @@ -162,10 +149,8 @@ int ProcessExecutor::handleRead(int rpipe, unsigned int &result)
std::exit(EXIT_FAILURE);
}

if (hasToLog(msg)) {
if (type == PipeWriter::REPORT_ERROR)
mErrorLogger.reportErr(msg);
}
if (hasToLog(msg))
mErrorLogger.reportErr(msg);
} else if (type == PipeWriter::CHILD_END) {
std::istringstream iss(buf);
unsigned int fileResult = 0;
Expand Down
20 changes: 4 additions & 16 deletions cli/threadexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,28 +113,16 @@ class SyncLogForwarder : public ErrorLogger
}

void reportErr(const ErrorMessage &msg) override {
report(msg, MessageType::REPORT_ERROR);
}

std::mutex mReportSync;

private:
enum class MessageType {REPORT_ERROR};

void report(const ErrorMessage &msg, MessageType msgType)
{
if (!mThreadExecutor.hasToLog(msg))
return;

std::lock_guard<std::mutex> lg(mReportSync);

switch (msgType) {
case MessageType::REPORT_ERROR:
mErrorLogger.reportErr(msg);
break;
}
mErrorLogger.reportErr(msg);
}

std::mutex mReportSync;

private:
ThreadExecutor &mThreadExecutor;
ErrorLogger &mErrorLogger;
};
Expand Down