Hi,

Here is the TSRM diff file in unified diff format.
I have used the command:  cvs diff -uN

Regards,
Ananth.

>>> Marcus Boerger <[EMAIL PROTECTED]> 1/30/2004 12:31:43 PM >>>
Hello Ananth,

please provide a unified diff (cvs di -u) and we cannot accept
precompiler statements starting after column 0. You *must* keep
this in mind. For a full list of rules to follow you can visit
the file CODING_STANDARDS.

regards
marcus

Friday, January 30, 2004, 7:11:23 AM, you wrote:

> Oops. I did not know that the system only accepts text/plain
> attachments. Here is the attachment for TSRM diff. This is in
> text format. I will send the diff for the whole project soon.

> Thanks,
> Ananth.

>>>> Derick Rethans <[EMAIL PROTECTED]> 1/29/2004 5:26:01 PM >>>
> On Thu, 29 Jan 2004, Ananth Kesari wrote:

>> Our changes are spread across many files, so I am not sure if we
can
>> checkin at this stage of the release of PHP 5.0. Anyway, I have
>> attached the diff file for TSRM. Please review the same and give me
>> your comments. There are similar changes in other files. If you
> think
>> I should send across the diffs for other files also, then I will do
>> so. Let me know.

> Just make *one* diff against latest CVS of all changes? And you
didn't
> add an attachment (we only accept text/plain attachments here).

>> In the meantime, I have a question. I am interested in contributing
>> to the Open source PHP. I was thinking that the good way to start
>> could be to begin working on some simple defects and fix them.
>> Can you let me know if I can do that and if yes, how? I mean,
>> where to look for the defects filed and what is the procedure to
>> start fixing them?

> Have a look at bugs.php.net, there are plenty of open bugs.

> regards,
> Derick




-- 
Best regards,
 Marcus                            mailto:[EMAIL PROTECTED] 

Index: ./tsrm/TSRM.c
===================================================================
RCS file: /repository/TSRM/TSRM.c,v
retrieving revision 1.55
diff -u -r1.55 TSRM.c
--- ./tsrm/TSRM.c       14 Dec 2003 15:41:50 -0000      1.55
+++ ./tsrm/TSRM.c       30 Jan 2004 12:45:28 -0000
@@ -106,6 +106,18 @@
        pth_init();
 #elif defined(PTHREADS)
        pthread_key_create( &tls_key, 0 );
+#ifdef NETWARE
+       /* Anantha Kesari
+        * For NetWare we have made it such a way that TSRM is started twice when
+        * Apache 2 is reloaded. When Apache2 is restarted, TSRM is started only once.
+        * Due to this, pthread_key_create is called twice. First time when TSRM
+        * is unloaded, the value associated with the key doesn't get cleared properly
+        * though the value itself is freed up. So for safety, the pthread_setspecific
+        * call below clears this value every time the key is created. Without this 
call,
+        * Apache 2.0 would crash even when it is loading.
+        */
+       pthread_setspecific(tls_key, 0);
+#endif
 #elif defined(TSRM_ST)
        st_init();
        st_key_create(&tls_key, 0);
@@ -294,15 +306,6 @@
        int hash_value;
        tsrm_tls_entry *thread_resources;
 
-#ifdef NETWARE
-       /* The below if loop is added for NetWare to fix an abend while unloading PHP
-        * when an Apache unload command is issued on the system console.
-        * While exiting from PHP, at the end for some reason, this function is called
-        * with tsrm_tls_table = NULL. When this happened, the server abends when
-        * tsrm_tls_table is accessed since it is NULL.
-        */
-       if(tsrm_tls_table) {
-#endif
        if (!th_id) {
 #if defined(PTHREADS)
                /* Fast path for looking up the resources for the current
@@ -365,9 +368,6 @@
         * changes to the structure as we read it.
         */
        TSRM_SAFE_RETURN_RSRC(thread_resources->storage, id, thread_resources->count);
-#ifdef NETWARE
-       }       /* if(tsrm_tls_table) */
-#endif
 }
 
 
@@ -434,13 +434,6 @@
 {
 #ifdef TSRM_WIN32
        return GetCurrentThreadId();
-#elif defined(NETWARE)
-       /* There seems to be some problem with the LibC call: NXThreadGetId().
-        * Due to this, the PHPMyAdmin application is abending in PHP calls.
-        * Used the call, kCurrentThread instead and it works fine.
-        */
-/*     return NXThreadGetId(); */
-       return kCurrentThread();
 #elif defined(GNUPTH)
        return pth_self();
 #elif defined(PTHREADS)
@@ -451,6 +444,20 @@
        return PIThread_getCurrent();
 #elif defined(TSRM_ST)
        return st_thread_self();
+#elif defined(NETWARE)
+/* Anantha Kesari. 20 Aug 2003.
+ *
+ * Apache 1.3 is Clib based and it creats the threads using Clib calls.
+ * PHP is LibC based and so here also we should use the Clib calls to
+ * get the ID for these threads. If not, there will be a mismatch in the
+ * threads created and its usage. This will lead to abend when complex scripts
+ * are run and also when multiple scripts are run simulataneously.
+ */
+#ifdef APACHE_2_BUILD
+       return NXThreadGetId();
+#else
+       return kCurrentThread();
+#endif
 #elif defined(BETHREADS)
        return find_thread(NULL);
 #endif
@@ -461,24 +468,10 @@
 TSRM_API MUTEX_T tsrm_mutex_alloc(void)
 {
        MUTEX_T mutexp;
-#ifdef NETWARE
-#ifndef USE_MPK
-       /* To use the Recursive Mutex Locking of LibC */
-       long flags = NX_MUTEX_RECURSIVE;
-       NXHierarchy_t order = 0;
-       NX_LOCK_INFO_ALLOC (lockInfo, "PHP-TSRM", 0);
-#endif
-#endif
 
 #ifdef TSRM_WIN32
        mutexp = malloc(sizeof(CRITICAL_SECTION));
        InitializeCriticalSection(mutexp);
-#elif defined(NETWARE)
-#ifdef USE_MPK
-       mutexp = kMutexAlloc((BYTE*)"PHP-TSRM");
-#else
-       mutexp = NXMutexAlloc(flags, order, &lockInfo);
-#endif
 #elif defined(GNUPTH)
        mutexp = (MUTEX_T) malloc(sizeof(*mutexp));
        pth_mutex_init(mutexp);
@@ -491,6 +484,17 @@
        mutexp = PIPlatform_allocLocalMutex();
 #elif defined(TSRM_ST)
        mutexp = st_mutex_new();
+#elif defined(NETWARE)
+       #ifdef USE_MPK
+               mutexp = kMutexAlloc((BYTE*)"PHP-TSRM");
+       #else
+               /* To use the Recursive Mutex Locking of LibC */
+               long flags = NX_MUTEX_RECURSIVE;
+               NXHierarchy_t order = 0;
+               NX_LOCK_INFO_ALLOC (lockInfo, "PHP-TSRM", 0);
+
+               mutexp = NXMutexAlloc(flags, order, &lockInfo);
+       #endif
 #elif defined(BETHREADS)
        mutexp = (beos_ben*)malloc(sizeof(beos_ben));
        mutexp->ben = 0;
@@ -510,12 +514,6 @@
 #ifdef TSRM_WIN32
                DeleteCriticalSection(mutexp);
                free(mutexp);
-#elif defined(NETWARE)
-#ifdef USE_MPK
-               kMutexFree(mutexp);
-#else
-               NXMutexFree(mutexp);
-#endif
 #elif defined(GNUPTH)
                free(mutexp);
 #elif defined(PTHREADS)
@@ -527,6 +525,12 @@
                PISync_delete(mutexp);
 #elif defined(TSRM_ST)
                st_mutex_destroy(mutexp);
+#elif defined(NETWARE)
+       #ifdef USE_MPK
+                       kMutexFree(mutexp);
+       #else
+                       NXMutexFree(mutexp);
+       #endif
 #elif defined(BETHREADS)
                delete_sem(mutexp->sem);
                free(mutexp);  
@@ -545,12 +549,6 @@
 #ifdef TSRM_WIN32
        EnterCriticalSection(mutexp);
        return 1;
-#elif defined(NETWARE)
-#ifdef USE_MPK
-       return kMutexLock(mutexp);
-#else
-       return NXLock(mutexp);
-#endif
 #elif defined(GNUPTH)
        return pth_mutex_acquire(mutexp, 0, NULL);
 #elif defined(PTHREADS)
@@ -561,6 +559,12 @@
        return PISync_lock(mutexp);
 #elif defined(TSRM_ST)
        return st_mutex_lock(mutexp);
+#elif defined(NETWARE)
+       #ifdef USE_MPK
+               return kMutexLock(mutexp);
+       #else
+               return NXLock(mutexp);
+       #endif
 #elif defined(BETHREADS)
        if (atomic_add(&mutexp->ben, 1) != 0)  
                return acquire_sem(mutexp->sem);   
@@ -576,12 +580,6 @@
 #ifdef TSRM_WIN32
        LeaveCriticalSection(mutexp);
        return 1;
-#elif defined(NETWARE)
-#ifdef USE_MPK
-       return kMutexUnlock(mutexp);
-#else
-       return NXUnlock(mutexp);
-#endif
 #elif defined(GNUPTH)
        return pth_mutex_release(mutexp);
 #elif defined(PTHREADS)
@@ -592,6 +590,12 @@
        return PISync_unlock(mutexp);
 #elif defined(TSRM_ST)
        return st_mutex_unlock(mutexp);
+#elif defined(NETWARE)
+       #ifdef USE_MPK
+               return kMutexUnlock(mutexp);
+       #else
+               return NXUnlock(mutexp);
+       #endif
 #elif defined(BETHREADS)
        if (atomic_add(&mutexp->ben, -1) != 1) 
                return release_sem(mutexp->sem);
Index: ./tsrm/TSRM.h
===================================================================
RCS file: /repository/TSRM/TSRM.h,v
retrieving revision 1.43
diff -u -r1.43 TSRM.h
--- ./tsrm/TSRM.h       3 Dec 2003 14:26:41 -0000       1.43
+++ ./tsrm/TSRM.h       30 Jan 2004 12:45:28 -0000
@@ -42,6 +42,12 @@
 # endif
 # include <windows.h>
 # include <shellapi.h>
+#elif defined(GNUPTH)
+# include <pth.h>
+#elif defined(PTHREADS)
+# include <pthread.h>
+#elif defined(TSRM_ST)
+# include <st.h>
 #elif defined(NETWARE)
 # include <nks/thread.h>
 #ifdef USE_MPK
@@ -49,12 +55,6 @@
 #else
 # include <nks/synch.h>
 #endif
-#elif defined(GNUPTH)
-# include <pth.h>
-#elif defined(PTHREADS)
-# include <pthread.h>
-#elif defined(TSRM_ST)
-# include <st.h>
 #elif defined(BETHREADS)
 #include <kernel/OS.h> 
 #include <TLS.h>
@@ -66,13 +66,6 @@
 #ifdef TSRM_WIN32
 # define THREAD_T DWORD
 # define MUTEX_T CRITICAL_SECTION *
-#elif defined(NETWARE)
-# define THREAD_T NXThreadId_t
-#ifdef USE_MPK
-# define MUTEX_T MUTEX
-#else
-# define MUTEX_T NXMutex_t *
-#endif
 #elif defined(GNUPTH)
 # define THREAD_T pth_t
 # define MUTEX_T pth_mutex_t *
@@ -88,6 +81,13 @@
 #elif defined(TSRM_ST)
 # define THREAD_T st_thread_t
 # define MUTEX_T st_mutex_t
+#elif defined(NETWARE)
+# define THREAD_T NXThreadId_t
+#ifdef USE_MPK
+# define MUTEX_T MUTEX
+#else
+# define MUTEX_T NXMutex_t *
+#endif
 #elif defined(BETHREADS)
 # define THREAD_T thread_id
 typedef struct {
Index: ./tsrm/acconfig.h
===================================================================
RCS file: /repository/TSRM/acconfig.h,v
retrieving revision 1.3
diff -u -r1.3 acconfig.h
--- ./tsrm/acconfig.h   24 Sep 1999 20:52:46 -0000      1.3
+++ ./tsrm/acconfig.h   30 Jan 2004 12:45:28 -0000
@@ -1 +1,24 @@
+/* Anantha Kesari. 20 Aug 2003.
+ *
+ * Define PTHREADS only for Apache 2 and not for Apache 1.3.
+ * This is because the former is LibC based and everything works fine in that case.
+ * The latter is Clib based and so the thread calls will change if we use PTHREADS
+ * and the server abends if we use PTHREADS in PHP for Apache 1.3.
+ *
+ * Explanation:
+ *
+ * In the case of Apache 1.3, pthread_self always returns 0 due to mismatch in
+ * the function calls used to create the treads and getting the IDs for them.
+ * (Threads are created by Apache 1.3 using Clib calls whereas LibC's PTHREAD call
+ * is used to get the ID for these threads).
+ * Now, using this thread specific ID returned by pthread_self, we store some
+ * thread specific data into different hash tables. When we execute multiple scripts
+ * simultaneously, since the ID is always 0, one thread reads/writs data from/into
+ * another thread's data area.
+ * This causes the server to abend.
+ */
+#ifdef APACHE_2_BUILD
+#define PTHREADS
+#else
 #undef PTHREADS
+#endif
Index: ./tsrm/tsrm_virtual_cwd.c
===================================================================
RCS file: /repository/TSRM/tsrm_virtual_cwd.c,v
retrieving revision 1.60
diff -u -r1.60 tsrm_virtual_cwd.c
--- ./tsrm/tsrm_virtual_cwd.c   8 Jan 2004 08:14:03 -0000       1.60
+++ ./tsrm/tsrm_virtual_cwd.c   30 Jan 2004 12:45:28 -0000
@@ -42,7 +42,6 @@
 #endif
 
 #ifdef NETWARE
-/*#include "pipe.h"*/
 #include "tsrm_nw.h"
 #endif
 
@@ -100,10 +99,12 @@
        (len == 1 && element[0] == '.')
 
 #elif defined(NETWARE)
-/* NetWare has strtok() (in LibC) and allows both slashes in paths, like Windows --
-   but rest of the stuff is like Unix */
-/* strtok() call in LibC is abending when used in a different address space -- hence 
using
-   PHP's version itself for now */
+/* NetWare has strtok() (in LibC) and allows both slashes in paths, like Windows.
+ * But rest of the stuff is like Unix
+ */
+/* strtok() call in LibC is abending when used in a different address space.
+ * Hence using PHP's version itself for now
+ */
 /*#define tsrm_strtok_r(a,b,c) strtok((a),(b))*/
 #define TOKENIZER_STRING "/\\"
 
@@ -139,18 +140,16 @@
 
 #define CWD_STATE_FREE(s)                      \
        free((s)->cwd);
-       
-static int php_is_dir_ok(const cwd_state *state) 
+
+static int php_is_dir_ok(const cwd_state *state)
 {
-#if !(defined(NETWARE) && defined(CLIB_STAT_PATCH))
+#if (defined(NETWARE) && defined(CLIB_STAT_PATCH))
+       struct stat_libc buf;
+#else
        struct stat buf;
+#endif
 
        if (stat(state->cwd, &buf) == 0 && S_ISDIR(buf.st_mode))
-#else
-    struct stat_libc buf;
-
-    if (stat(state->cwd, (struct stat*)(&buf)) == 0 && S_ISDIR(buf.st_mode))
-#endif
                return (0);
 
        return (1);
@@ -158,15 +157,13 @@
 
 static int php_is_file_ok(const cwd_state *state) 
 {
-#if !(defined(NETWARE) && defined(CLIB_STAT_PATCH))
+#if (defined(NETWARE) && defined(CLIB_STAT_PATCH))
+       struct stat_libc buf;
+#else
        struct stat buf;
+#endif
 
        if (stat(state->cwd, &buf) == 0 && S_ISREG(buf.st_mode))
-#else
-    struct stat_libc buf;
-
-    if (stat(state->cwd, (struct stat*)(&buf)) == 0 && S_ISREG(buf.st_mode))
-#endif
                return (0);
 
        return (1);
@@ -373,6 +370,9 @@
 #ifdef TSRM_WIN32
        } else if (IS_SLASH(path_copy[0])) {
                copy_amount = 2;
+#elif defined(NETWARE)
+       } else if (IS_SLASH(path_copy[0])) {
+               copy_amount = 4;        /* This is the size of the string "sys:" which 
is 4 */
 #endif
        }
 
@@ -693,8 +693,11 @@
        return retval;
 }
 
-#if !(defined(NETWARE) && defined(CLIB_STAT_PATCH))
+#if (defined(NETWARE) && defined(CLIB_STAT_PATCH))
+CWD_API int virtual_stat(const char *path, struct stat_libc *buf TSRMLS_DC)
+#else
 CWD_API int virtual_stat(const char *path, struct stat *buf TSRMLS_DC)
+#endif
 {
        cwd_state new_state;
        int retval;
@@ -707,21 +710,6 @@
        CWD_STATE_FREE(&new_state);
        return retval;
 }
-#else
-CWD_API int virtual_stat(const char *path, struct stat_libc *buf TSRMLS_DC)
-{
-       cwd_state new_state;
-       int retval;
-
-       CWD_STATE_COPY(&new_state, &CWDG(cwd));
-       virtual_file_ex(&new_state, path, NULL, 1);
-
-       retval = stat(new_state.cwd, (struct stat*)buf);
-
-       CWD_STATE_FREE(&new_state);
-       return retval;
-}
-#endif
 
 #if !defined(TSRM_WIN32) && !defined(NETWARE)
 CWD_API int virtual_lstat(const char *path, struct stat *buf TSRMLS_DC)
@@ -811,8 +799,8 @@
 
 #elif defined(NETWARE)
 
-/* On NetWare, the trick of prepending "cd cwd; " doesn't work so we need to perform
-   a VCWD_CHDIR() and mutex it
+/* On NetWare, the trick of prepending "cd cwd;" doesn't work.
+ * So we need to perform a VCWD_CHDIR() and mutex it.
  */
 CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC)
 {
Index: ./tsrm/tsrm_virtual_cwd.h
===================================================================
RCS file: /repository/TSRM/tsrm_virtual_cwd.h,v
retrieving revision 1.42
diff -u -r1.42 tsrm_virtual_cwd.h
--- ./tsrm/tsrm_virtual_cwd.h   8 Jan 2004 17:31:46 -0000       1.42
+++ ./tsrm/tsrm_virtual_cwd.h   30 Jan 2004 12:45:28 -0000
@@ -141,10 +141,10 @@
 CWD_API int virtual_open(const char *path TSRMLS_DC, int flags, ...);
 CWD_API int virtual_creat(const char *path, mode_t mode TSRMLS_DC);
 CWD_API int virtual_rename(char *oldname, char *newname TSRMLS_DC);
-#if !(defined(NETWARE) && defined(CLIB_STAT_PATCH))
-CWD_API int virtual_stat(const char *path, struct stat *buf TSRMLS_DC);
-#else
+#if (defined(NETWARE) && defined(CLIB_STAT_PATCH))
 CWD_API int virtual_stat(const char *path, struct stat_libc *buf TSRMLS_DC);
+#else
+CWD_API int virtual_stat(const char *path, struct stat *buf TSRMLS_DC);
 #endif
 #if !defined(TSRM_WIN32) && !defined(NETWARE)
 CWD_API int virtual_lstat(const char *path, struct stat *buf TSRMLS_DC);

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

Reply via email to