Skip to content

Commit 96c2056

Browse files
author
Anantha Kesari H Y
committed
NetWare related changes/modifications.
1 parent 2410f76 commit 96c2056

File tree

8 files changed

+373
-220
lines changed

8 files changed

+373
-220
lines changed

TSRM/TSRM.c

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,13 @@ TSRM_API void *ts_resource_ex(ts_rsrc_id id, THREAD_T *th_id)
286286
int hash_value;
287287
tsrm_tls_entry *thread_resources;
288288

289+
/* The below if loop is added for NetWare to fix an abend while unloading PHP
290+
* when an Apache unload command is issued on the system console.
291+
* While exiting from PHP, at the end for some reason, this function is called
292+
* with tsrm_tls_table = NULL. When this happened, the server abends when
293+
* tsrm_tls_table is accessed since it is NULL.
294+
*/
295+
if(tsrm_tls_table) {
289296
if (!th_id) {
290297
#if defined(PTHREADS)
291298
/* Fast path for looking up the resources for the current
@@ -346,6 +353,7 @@ TSRM_API void *ts_resource_ex(ts_rsrc_id id, THREAD_T *th_id)
346353
* changes to the structure as we read it.
347354
*/
348355
TSRM_SAFE_RETURN_RSRC(thread_resources->storage, id, thread_resources->count);
356+
} /* if(tsrm_tls_table) */
349357
}
350358

351359

@@ -412,6 +420,13 @@ TSRM_API THREAD_T tsrm_thread_id(void)
412420
{
413421
#ifdef TSRM_WIN32
414422
return GetCurrentThreadId();
423+
#elif defined(NETWARE)
424+
/* There seems to be some problem with the LibC call, NXThreadGetId
425+
* due to which the PHPMyAdmin application was abending in PHP calls.
426+
* Used the MPK call kCurrentThread instead. Need to check this again.
427+
*/
428+
/* return NXThreadGetId(); */
429+
return kCurrentThread();
415430
#elif defined(GNUPTH)
416431
return pth_self();
417432
#elif defined(PTHREADS)
@@ -430,10 +445,24 @@ TSRM_API THREAD_T tsrm_thread_id(void)
430445
TSRM_API MUTEX_T tsrm_mutex_alloc(void)
431446
{
432447
MUTEX_T mutexp;
448+
#ifdef NETWARE
449+
#ifndef USE_MPK
450+
/* To use the Recursive Mutex Locking of LibC */
451+
long flags = NX_MUTEX_RECURSIVE;
452+
NXHierarchy_t order = 0;
453+
NX_LOCK_INFO_ALLOC (lockInfo, "PHP-TSRM", 0);
454+
#endif
455+
#endif
433456

434457
#ifdef TSRM_WIN32
435458
mutexp = malloc(sizeof(CRITICAL_SECTION));
436459
InitializeCriticalSection(mutexp);
460+
#elif defined(NETWARE)
461+
#ifdef USE_MPK
462+
mutexp = kMutexAlloc((BYTE*)"PHP-TSRM");
463+
#else
464+
mutexp = NXMutexAlloc(flags, order, &lockInfo);
465+
#endif
437466
#elif defined(GNUPTH)
438467
mutexp = (MUTEX_T) malloc(sizeof(*mutexp));
439468
pth_mutex_init(mutexp);
@@ -460,6 +489,12 @@ TSRM_API void tsrm_mutex_free(MUTEX_T mutexp)
460489
if (mutexp) {
461490
#ifdef TSRM_WIN32
462491
DeleteCriticalSection(mutexp);
492+
#elif defined(NETWARE)
493+
#ifdef USE_MPK
494+
kMutexFree(mutexp);
495+
#else
496+
NXMutexFree(mutexp);
497+
#endif
463498
#elif defined(GNUPTH)
464499
free(mutexp);
465500
#elif defined(PTHREADS)
@@ -486,6 +521,12 @@ TSRM_API int tsrm_mutex_lock(MUTEX_T mutexp)
486521
#ifdef TSRM_WIN32
487522
EnterCriticalSection(mutexp);
488523
return 1;
524+
#elif defined(NETWARE)
525+
#ifdef USE_MPK
526+
return kMutexLock(mutexp);
527+
#else
528+
return NXLock(mutexp);
529+
#endif
489530
#elif defined(GNUPTH)
490531
return pth_mutex_acquire(mutexp, 0, NULL);
491532
#elif defined(PTHREADS)
@@ -507,6 +548,12 @@ TSRM_API int tsrm_mutex_unlock(MUTEX_T mutexp)
507548
#ifdef TSRM_WIN32
508549
LeaveCriticalSection(mutexp);
509550
return 1;
551+
#elif defined(NETWARE)
552+
#ifdef USE_MPK
553+
return kMutexUnlock(mutexp);
554+
#else
555+
return NXUnlock(mutexp);
556+
#endif
510557
#elif defined(GNUPTH)
511558
return pth_mutex_release(mutexp);
512559
#elif defined(PTHREADS)

TSRM/TSRM.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@
3636

3737
#ifdef TSRM_WIN32
3838
# include <windows.h>
39+
#elif defined(NETWARE)
40+
# include <nks/thread.h>
41+
#ifdef USE_MPK
42+
# include <mpklib4php.h>
43+
#else
44+
# include <nks/synch.h>
45+
#endif
3946
#elif defined(GNUPTH)
4047
# include <pth.h>
4148
#elif defined(PTHREADS)
@@ -50,6 +57,13 @@ typedef int ts_rsrc_id;
5057
#ifdef TSRM_WIN32
5158
# define THREAD_T DWORD
5259
# define MUTEX_T CRITICAL_SECTION *
60+
#elif defined(NETWARE)
61+
# define THREAD_T NXThreadId_t
62+
#ifdef USE_MPK
63+
# define MUTEX_T MUTEX
64+
#else
65+
# define MUTEX_T NXMutex_t *
66+
#endif
5367
#elif defined(GNUPTH)
5468
# define THREAD_T pth_t
5569
# define MUTEX_T pth_mutex_t *

TSRM/tsrm_config.nw.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
12
#ifndef TSRM_CONFIG_NW_H
23
#define TSRM_CONFIG_NW_H
34

45
#define HAVE_UTIME 1
56

6-
/* Though we have alloca(), this seems to be causing some problem with the stack pointer -- hence not using it */
7-
/* #define HAVE_ALLOCA 1 */
7+
/* Though we have alloca(), this seems to be causing some problem
8+
* with the stack pointer. Hence not using it
9+
*/
10+
/*#define HAVE_ALLOCA 1*/
811

912
#endif

TSRM/tsrm_config_common.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
# define TSRM_WIN32
66
#endif
77

8-
#ifndef TSRM_WIN32
8+
#ifdef TSRM_WIN32
9+
# include "tsrm_config.w32.h"
10+
#elif defined(NETWARE)
11+
# include "tsrm_config.nw.h"
12+
#else
913
# include "tsrm_config.h"
1014
# include <sys/param.h>
11-
#else
12-
# include "tsrm_config.w32.h"
1315
#endif
1416

1517
#ifdef TSRM_WIN32

0 commit comments

Comments
 (0)