@@ -286,6 +286,13 @@ TSRM_API void *ts_resource_ex(ts_rsrc_id id, THREAD_T *th_id)
286
286
int hash_value ;
287
287
tsrm_tls_entry * thread_resources ;
288
288
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 ) {
289
296
if (!th_id ) {
290
297
#if defined(PTHREADS )
291
298
/* 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)
346
353
* changes to the structure as we read it.
347
354
*/
348
355
TSRM_SAFE_RETURN_RSRC (thread_resources -> storage , id , thread_resources -> count );
356
+ } /* if(tsrm_tls_table) */
349
357
}
350
358
351
359
@@ -412,6 +420,13 @@ TSRM_API THREAD_T tsrm_thread_id(void)
412
420
{
413
421
#ifdef TSRM_WIN32
414
422
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 ();
415
430
#elif defined(GNUPTH )
416
431
return pth_self ();
417
432
#elif defined(PTHREADS )
@@ -430,10 +445,24 @@ TSRM_API THREAD_T tsrm_thread_id(void)
430
445
TSRM_API MUTEX_T tsrm_mutex_alloc (void )
431
446
{
432
447
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
433
456
434
457
#ifdef TSRM_WIN32
435
458
mutexp = malloc (sizeof (CRITICAL_SECTION ));
436
459
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
437
466
#elif defined(GNUPTH )
438
467
mutexp = (MUTEX_T ) malloc (sizeof (* mutexp ));
439
468
pth_mutex_init (mutexp );
@@ -460,6 +489,12 @@ TSRM_API void tsrm_mutex_free(MUTEX_T mutexp)
460
489
if (mutexp ) {
461
490
#ifdef TSRM_WIN32
462
491
DeleteCriticalSection (mutexp );
492
+ #elif defined(NETWARE )
493
+ #ifdef USE_MPK
494
+ kMutexFree (mutexp );
495
+ #else
496
+ NXMutexFree (mutexp );
497
+ #endif
463
498
#elif defined(GNUPTH )
464
499
free (mutexp );
465
500
#elif defined(PTHREADS )
@@ -486,6 +521,12 @@ TSRM_API int tsrm_mutex_lock(MUTEX_T mutexp)
486
521
#ifdef TSRM_WIN32
487
522
EnterCriticalSection (mutexp );
488
523
return 1 ;
524
+ #elif defined(NETWARE )
525
+ #ifdef USE_MPK
526
+ return kMutexLock (mutexp );
527
+ #else
528
+ return NXLock (mutexp );
529
+ #endif
489
530
#elif defined(GNUPTH )
490
531
return pth_mutex_acquire (mutexp , 0 , NULL );
491
532
#elif defined(PTHREADS )
@@ -507,6 +548,12 @@ TSRM_API int tsrm_mutex_unlock(MUTEX_T mutexp)
507
548
#ifdef TSRM_WIN32
508
549
LeaveCriticalSection (mutexp );
509
550
return 1 ;
551
+ #elif defined(NETWARE )
552
+ #ifdef USE_MPK
553
+ return kMutexUnlock (mutexp );
554
+ #else
555
+ return NXUnlock (mutexp );
556
+ #endif
510
557
#elif defined(GNUPTH )
511
558
return pth_mutex_release (mutexp );
512
559
#elif defined(PTHREADS )
0 commit comments