Skip to content

Commit

Permalink
- darwintrace: fixed crash when used by multi-threaded applications
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.macosforge.org/repository/darwinbuild/trunk@1032 10a61168-4876-4dac-953b-31e694342555
  • Loading branch information
kvanvechten committed Mar 22, 2012
1 parent f9f3c5a commit a6acf01
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Darwin Build Scripts Change History
-----------------------------------
Release 31 [22-Mar-2012]
- darwintrace: fixed crash when used by multi-threaded applications

Release 30 [15-Mar-2012]
- darwinup: not detecting installs into /System/Library/Sandbox/Profiles

Expand Down
10 changes: 7 additions & 3 deletions darwintrace/darwintrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

#include <crt_externs.h>
#include <fcntl.h>
#include <pthread.h>
#include <spawn.h>
#include <stdarg.h>
#include <stdio.h>
Expand Down Expand Up @@ -141,9 +142,7 @@ static inline void darwintrace_free_path(char* path, const char* test) {
if (path != test) free(path);
}

static inline void darwintrace_setup() {
if (darwintrace_fd != -2) return;

static void _darwintrace_setup(void) {
char* path = getenv("DARWINTRACE_LOG");
if (path != NULL) {
int olderrno = errno;
Expand Down Expand Up @@ -222,6 +221,11 @@ static inline void darwintrace_setup() {
}
}

static inline void darwintrace_setup(void) {
static pthread_once_t once = PTHREAD_ONCE_INIT;
pthread_once(&once, &_darwintrace_setup);
}

/* darwintrace_setup must have been called already */
static inline void darwintrace_logpath(int fd, const char *procname, char *tag, const char *path) {
if (darwintrace_ignores) {
Expand Down

0 comments on commit a6acf01

Please sign in to comment.