Some cleanup for base/logging and base/stream.h
* Fix race when calling UpdateMinLogSeverity * Remove unused 'diagnostic mode' * Remove LogToStream * Fix ctor of StringStream * Delete POpenStream * Delete AsyncWriteStream * Delete CircularFileStream * Delete StreamSegment BUG= R=pbos@webrtc.org Review URL: https://webrtc-codereview.appspot.com/57429004 Cr-Commit-Position: refs/heads/master@{#9273}
This commit is contained in:
@ -258,63 +258,6 @@ static void ExpectEofFromStream(FileStream* stream) {
|
||||
}
|
||||
}
|
||||
|
||||
// For caching the lsb_release output (reading it invokes a sub-process and
|
||||
// hence is somewhat expensive).
|
||||
static std::string lsb_release_string;
|
||||
static CriticalSection lsb_release_string_critsec;
|
||||
|
||||
std::string ReadLinuxLsbRelease() {
|
||||
CritScope cs(&lsb_release_string_critsec);
|
||||
if (!lsb_release_string.empty()) {
|
||||
// Have cached result from previous call.
|
||||
return lsb_release_string;
|
||||
}
|
||||
// No cached result. Run lsb_release and parse output.
|
||||
POpenStream lsb_release_output;
|
||||
if (!lsb_release_output.Open("lsb_release -idrcs", "r", NULL)) {
|
||||
LOG_ERR(LS_ERROR) << "Can't run lsb_release";
|
||||
return lsb_release_string; // empty
|
||||
}
|
||||
// Read in the command's output and build the string.
|
||||
std::ostringstream sstr;
|
||||
std::string line;
|
||||
int wait_status;
|
||||
|
||||
if (!ExpectLineFromStream(&lsb_release_output, &line)) {
|
||||
return lsb_release_string; // empty
|
||||
}
|
||||
sstr << "DISTRIB_ID=" << line;
|
||||
|
||||
if (!ExpectLineFromStream(&lsb_release_output, &line)) {
|
||||
return lsb_release_string; // empty
|
||||
}
|
||||
sstr << " DISTRIB_DESCRIPTION=\"" << line << '"';
|
||||
|
||||
if (!ExpectLineFromStream(&lsb_release_output, &line)) {
|
||||
return lsb_release_string; // empty
|
||||
}
|
||||
sstr << " DISTRIB_RELEASE=" << line;
|
||||
|
||||
if (!ExpectLineFromStream(&lsb_release_output, &line)) {
|
||||
return lsb_release_string; // empty
|
||||
}
|
||||
sstr << " DISTRIB_CODENAME=" << line;
|
||||
|
||||
// Should not be anything left.
|
||||
ExpectEofFromStream(&lsb_release_output);
|
||||
|
||||
lsb_release_output.Close();
|
||||
wait_status = lsb_release_output.GetWaitStatus();
|
||||
if (wait_status == -1 ||
|
||||
!WIFEXITED(wait_status) ||
|
||||
WEXITSTATUS(wait_status) != 0) {
|
||||
LOG(LS_WARNING) << "Unexpected exit status from lsb_release";
|
||||
}
|
||||
|
||||
lsb_release_string = sstr.str();
|
||||
|
||||
return lsb_release_string;
|
||||
}
|
||||
#endif
|
||||
|
||||
std::string ReadLinuxUname() {
|
||||
|
||||
Reference in New Issue
Block a user