Hi Rasmus,

> > This is no longer the case. E.g. when compiling the module for the NSAPI
> > webserver (Sun Java System Webserver) there should be a global define
> like
> > -DNSAPI in the makefiles (not only for nsapi.c) which is not. Because of
> > that all SAPIs do not have an effect on the thread implementation. When
> > compiling PHP with ZTS you always get an .o file that links to pthreads.
> > This must be the case, because without that it would not be possible to
> link
> > a CLI PHP in parallel to the webserver specific SAPI.
> 
> That's simply not the case.  Look at the nsapi code:
> 
> #define NSAPI 1
> 
> #ifdef HAVE_CONFIG_H
> #include "config.h"
> #endif
> 
> #include "php.h"
> #include "php_variables.h"
> #include "ext/standard/info.h"
> #include "php_ini.h"
> #include "php_globals.h"
> #include "SAPI.h"
> #include "php_main.h"
> #include "php_version.h"
> #include "TSRM.h"
> #include "ext/standard/php_standard.h"
> #include <sys/types.h>
> #include <sys/stat.h>
> 
> It defines NSAPI before including TSRM.h and in TSRM.h we have:
> 
> #elif defined(NSAPI)
> # define THREAD_T SYS_THREAD
> # define MUTEX_T CRITICAL

Butt his is only for nsapi.c. All other PHP modules and the core itself do
not know anything about NSAPI. This leads to the fact that if the webservers
thread implementation is incompatible to the system default the build .o of
nsapi.c is not compatible to the other .o files.

This happens here:
When compiling TSRM.c with the lines in it:

TSRM_API THREAD_T tsrm_thread_id(void)
{
#ifdef TSRM_WIN32
        return GetCurrentThreadId();
#elif defined(GNUPTH)
        return pth_self();
#elif defined(PTHREADS)
        return pthread_self();
#elif defined(NSAPI)
        return systhread_current();
#elif defined(PI3WEB)
        return PIThread_getCurrent();
#elif defined(TSRM_ST)
        return st_thread_self();
#elif defined(BETHREADS)
        return find_thread(NULL);
#endif
}

NSAPI is *not* defined. This is not a problem because the
systhread_current()-NSAPI function internally calls pthread_self() but only
if the webserver runs in pthreads.
On AIX (or was it HP-UX??? I should look into my bug reports) the webserver
runs in another thread implementation. This leads to crashes in the
webserver because PHP uses pthreads (because of TSRM.c) and all the
webserver another one. In the worst case
        #define THREAD_T SYS_THREAD
is also incompatible in size and structure and misbehaves between SAPI code
(with define) and PHP (without define).

Uwe

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to