*** mod_python.c.dist Fri Sep 24 15:11:32 2004 --- mod_python.c Sat Oct 16 22:36:30 2004 *************** *** 31,36 **** --- 31,38 ---- * (In a Python dictionary) */ static PyObject * interpreters = NULL; + static apr_thread_mutex_t* interpreters_lock = 0; + apr_pool_t *child_init_pool = NULL; /** *************** *** 124,129 **** --- 126,133 ---- name = MAIN_INTERPRETER; #ifdef WITH_THREAD + apr_thread_mutex_lock(interpreters_lock); + PyEval_AcquireLock(); #endif *************** *** 149,154 **** --- 153,160 ---- #ifdef WITH_THREAD PyEval_ReleaseLock(); + + apr_thread_mutex_unlock(interpreters_lock); #endif if (! idata) { *************** *** 469,474 **** --- 475,483 ---- const char *userdata_key = "python_init"; apr_status_t rc; + /* fudge for Mac OS X with Apache 1.3 where Py_IsInitialized() broke */ + static int initialized = 0; + apr_pool_userdata_get(&data, userdata_key, s->process->pool); if (!data) { apr_pool_userdata_set((const void *)1, userdata_key, *************** *** 490,502 **** } /* initialize global Python interpreter if necessary */ ! if (! Py_IsInitialized()) { /* initialze the interpreter */ Py_Initialize(); #ifdef WITH_THREAD /* create and acquire the interpreter lock */ PyEval_InitThreads(); #endif --- 499,514 ---- } /* initialize global Python interpreter if necessary */ ! if (initialized == 0 || ! Py_IsInitialized()) { + initialized = 1; /* initialze the interpreter */ Py_Initialize(); #ifdef WITH_THREAD + apr_thread_mutex_create(&interpreters_lock,APR_THREAD_MUTEX_UNNESTED,p); + /* create and acquire the interpreter lock */ PyEval_InitThreads(); #endif