From c5f25dc15d6642bcedbde1df42392c9ab6c07e0b Mon Sep 17 00:00:00 2001 From: Martijn Otto Date: Tue, 3 Nov 2015 14:32:17 +0100 Subject: [PATCH] Made the isolate used thread_local, which might fix intermittent crashes --- .gitignore | 1 + Makefile | 8 +++++++- isolate.cpp | 4 ++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 9d22eb4..fd9c310 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.o *.so +*.d diff --git a/Makefile b/Makefile index e138fed..57c5fbb 100644 --- a/Makefile +++ b/Makefile @@ -85,7 +85,7 @@ LINKER = c++ # with a list of all flags that should be passed to the linker. # -COMPILER_FLAGS = -Wall -c -O2 -std=c++11 -fpic -DVERSION="`./version.sh`" -I. -g +COMPILER_FLAGS = -Wall -c -O2 -MD -std=c++11 -fpic -DVERSION="`./version.sh`" -I. -g LINKER_FLAGS = -shared LINKER_DEPENDENCIES = -lphpcpp -lv8 @@ -112,6 +112,7 @@ MKDIR = mkdir -p SOURCES = $(wildcard *.cpp) OBJECTS = $(SOURCES:%.cpp=%.o) +DEPENDENCIES = $(SOURCES:%.cpp=%.d) # @@ -120,6 +121,11 @@ OBJECTS = $(SOURCES:%.cpp=%.o) all: ${OBJECTS} ${EXTENSION} +# +# Use dependency tracking +# +-include ${DEPENDENCIES} + ${EXTENSION}: ${OBJECTS} ${LINKER} ${LINKER_FLAGS} -o $@ ${OBJECTS} ${LINKER_DEPENDENCIES} diff --git a/isolate.cpp b/isolate.cpp index 2a252dc..f90a8fb 100644 --- a/isolate.cpp +++ b/isolate.cpp @@ -99,8 +99,8 @@ class Isolate final */ v8::Isolate* isolate() { - // the one and only isolate - static Isolate isolate; + // the one and only isolate in this thread + static thread_local Isolate isolate; // cast it to the right type return isolate;