Skip to content
Merged
Changes from all commits
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
Crashlytics: Add dispatch_once for opening sdk log file
  • Loading branch information
cltnschlosser committed Jun 24, 2020
commit 0238ebe065a708463533160c54ad4186fb970dd7
11 changes: 8 additions & 3 deletions Crashlytics/Crashlytics/Helpers/FIRCLSInternalLogging.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include <dispatch/dispatch.h>

#include "FIRCLSInternalLogging.h"
#include "FIRCLSContext.h"
#include "FIRCLSGlobals.h"
Expand All @@ -31,9 +33,12 @@ void FIRCLSSDKFileLog(FIRCLSInternalLogLevel level, const char* format, ...) {
return;
}

if (_firclsContext.writable->internalLogging.logFd == -1) {
_firclsContext.writable->internalLogging.logFd = open(path, O_WRONLY | O_CREAT | O_APPEND, 0644);
}
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
if (_firclsContext.writable->internalLogging.logFd == -1) {
_firclsContext.writable->internalLogging.logFd = open(path, O_WRONLY | O_CREAT | O_APPEND, 0644);
}
});

const int fd = _firclsContext.writable->internalLogging.logFd;
if (fd < 0) {
Expand Down