From 99736a1d60d1742a05de5bf82b8540c64082dbe2 Mon Sep 17 00:00:00 2001 From: boz Date: Thu, 8 Nov 2007 03:29:54 +0000 Subject: [PATCH] PHPEMBED: init lock needs to last longer Summary: if it didn't, a race condition could cause one host to try to use the interpreter before it was ready Reviewed By: dreiss Test Plan: ran the worker for a subset git-svn-id: svn+ssh://tubbs/svnroot/projects/phpembed/trunk@68715 2c7ba8d8-a2f7-0310-a573-de162e16dcc7 --- src/php_cxx.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/php_cxx.cpp b/src/php_cxx.cpp index 4a3aea6..a091b80 100644 --- a/src/php_cxx.cpp +++ b/src/php_cxx.cpp @@ -997,10 +997,10 @@ int php::init_global_php(){ #ifdef ZTS tsrm_mutex_lock(p.init_lock); p.clients++; - if(p.initialized == true) + if(p.initialized == true){ + tsrm_mutex_unlock(p.init_lock); return SUCCESS; - p.initialized = true; - tsrm_mutex_unlock(p.init_lock); + } #endif // set up the callbacks @@ -1055,6 +1055,11 @@ int php::init_global_php(){ zend_llist_init(&global_vars, sizeof(char *), NULL, 0); +#ifdef ZTS + p.initialized = true; + tsrm_mutex_unlock(p.init_lock); +#endif + return SUCCESS; // END ADAPTED php_embed_init }