Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(580)

Unified Diff: webrtc/call/rtc_event_log.cc

Issue 2015543002: Take ownership and close the platform file even if we fail to start logging. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/call/rtc_event_log.cc
diff --git a/webrtc/call/rtc_event_log.cc b/webrtc/call/rtc_event_log.cc
index 6dd02c808ebb5421405c1512c45c4db96f49502d..f09acc4a189c79ebf5900fe17c3fd998dedd9076 100644
--- a/webrtc/call/rtc_event_log.cc
+++ b/webrtc/call/rtc_event_log.cc
@@ -49,6 +49,10 @@ class RtcEventLogNullImpl final : public RtcEventLog {
}
bool StartLogging(rtc::PlatformFile platform_file,
int64_t max_size_bytes) override {
+ // The platform_file is open and needs to be closed.
+ if (!rtc::ClosePlatformFile(platform_file)) {
+ LOG(LS_WARNING) << "Can't close file.";
+ }
return false;
}
void StopLogging() override {}
@@ -190,6 +194,7 @@ bool RtcEventLogImpl::StartLogging(const std::string& file_name,
message.stop_time = std::numeric_limits<int64_t>::max();
message.file.reset(FileWrapper::Create());
if (message.file->OpenFile(file_name.c_str(), false) != 0) {
+ LOG(LS_WARNING) << "Can't open file. Logging not started.";
ivoc 2016/05/26 08:56:58 "Logging" sounds a bit vague to me, how about some
pbos-webrtc 2016/05/26 12:05:18 All of these are errors and should log on LS_ERROR
terelius 2016/05/26 14:54:42 Done.
terelius 2016/05/26 14:54:42 Done.
return false;
}
if (!message_queue_.Insert(&message)) {
@@ -212,9 +217,16 @@ bool RtcEventLogImpl::StartLogging(rtc::PlatformFile platform_file,
message.file.reset(FileWrapper::Create());
FILE* file_handle = rtc::FdopenPlatformFileForWriting(platform_file);
if (!file_handle) {
+ LOG(LS_WARNING) << "Can't open file. Logging not started.";
ivoc 2016/05/26 08:56:59 Same here.
terelius 2016/05/26 14:54:42 Done.
+ // Even though we failed to open a FILE*, the platform_file is still open
+ // and needs to be closed.
+ if (!rtc::ClosePlatformFile(platform_file)) {
+ LOG(LS_WARNING) << "Can't close file.";
+ }
return false;
}
if (message.file->OpenFromFileHandle(file_handle, true, false) != 0) {
+ LOG(LS_WARNING) << "Can't open file. Logging not started.";
ivoc 2016/05/26 08:56:59 Same here.
terelius 2016/05/26 14:54:42 Done.
return false;
}
if (!message_queue_.Insert(&message)) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698