@@ -158,6 +158,9 @@ TSRM_API void tsrm_shutdown(void)
158
158
159
159
next_p = p -> next ;
160
160
for (j = 0 ; j < id_count ; j ++ ) {
161
+ if (resource_types_table && resource_types_table [j ].dtor ) {
162
+ resource_types_table [j ].dtor (p -> storage [j ], & p -> storage );
163
+ }
161
164
free (p -> storage [j ]);
162
165
}
163
166
free (p -> storage );
@@ -290,6 +293,15 @@ TSRM_API void *ts_resource_ex(ts_rsrc_id id, THREAD_T *th_id)
290
293
int hash_value ;
291
294
tsrm_tls_entry * thread_resources ;
292
295
296
+ #ifdef NETWARE
297
+ /* The below if loop is added for NetWare to fix an abend while unloading PHP
298
+ * when an Apache unload command is issued on the system console.
299
+ * While exiting from PHP, at the end for some reason, this function is called
300
+ * with tsrm_tls_table = NULL. When this happened, the server abends when
301
+ * tsrm_tls_table is accessed since it is NULL.
302
+ */
303
+ if (tsrm_tls_table ) {
304
+ #endif
293
305
if (!th_id ) {
294
306
#if defined(PTHREADS )
295
307
/* Fast path for looking up the resources for the current
@@ -352,6 +364,9 @@ TSRM_API void *ts_resource_ex(ts_rsrc_id id, THREAD_T *th_id)
352
364
* changes to the structure as we read it.
353
365
*/
354
366
TSRM_SAFE_RETURN_RSRC (thread_resources -> storage , id , thread_resources -> count );
367
+ #ifdef NETWARE
368
+ } /* if(tsrm_tls_table) */
369
+ #endif
355
370
}
356
371
357
372
@@ -419,7 +434,12 @@ TSRM_API THREAD_T tsrm_thread_id(void)
419
434
#ifdef TSRM_WIN32
420
435
return GetCurrentThreadId ();
421
436
#elif defined(NETWARE )
422
- return NXThreadGetId ();
437
+ /* There seems to be some problem with the LibC call: NXThreadGetId().
438
+ * Due to this, the PHPMyAdmin application is abending in PHP calls.
439
+ * Used the call, kCurrentThread instead and it works fine.
440
+ */
441
+ /* return NXThreadGetId(); */
442
+ return kCurrentThread ();
423
443
#elif defined(GNUPTH )
424
444
return pth_self ();
425
445
#elif defined(PTHREADS )
@@ -441,16 +461,23 @@ TSRM_API MUTEX_T tsrm_mutex_alloc(void)
441
461
{
442
462
MUTEX_T mutexp ;
443
463
#ifdef NETWARE
444
- long flags = 0 ; /* Don't require NX_MUTEX_RECURSIVE, I guess */
464
+ #ifndef USE_MPK
465
+ /* To use the Recursive Mutex Locking of LibC */
466
+ long flags = NX_MUTEX_RECURSIVE ;
445
467
NXHierarchy_t order = 0 ;
446
468
NX_LOCK_INFO_ALLOC (lockInfo , "PHP-TSRM" , 0 );
447
- #endif
469
+ #endif
470
+ #endif
448
471
449
472
#ifdef TSRM_WIN32
450
473
mutexp = malloc (sizeof (CRITICAL_SECTION ));
451
474
InitializeCriticalSection (mutexp );
452
475
#elif defined(NETWARE )
453
- mutexp = NXMutexAlloc (flags , order , & lockInfo ); /* return value ignored for now */
476
+ #ifdef USE_MPK
477
+ mutexp = kMutexAlloc ((BYTE * )"PHP-TSRM" );
478
+ #else
479
+ mutexp = NXMutexAlloc (flags , order , & lockInfo );
480
+ #endif
454
481
#elif defined(GNUPTH )
455
482
mutexp = (MUTEX_T ) malloc (sizeof (* mutexp ));
456
483
pth_mutex_init (mutexp );
@@ -481,8 +508,13 @@ TSRM_API void tsrm_mutex_free(MUTEX_T mutexp)
481
508
if (mutexp ) {
482
509
#ifdef TSRM_WIN32
483
510
DeleteCriticalSection (mutexp );
511
+ free (mutexp );
484
512
#elif defined(NETWARE )
513
+ #ifdef USE_MPK
514
+ kMutexFree (mutexp );
515
+ #else
485
516
NXMutexFree (mutexp );
517
+ #endif
486
518
#elif defined(GNUPTH )
487
519
free (mutexp );
488
520
#elif defined(PTHREADS )
@@ -513,7 +545,11 @@ TSRM_API int tsrm_mutex_lock(MUTEX_T mutexp)
513
545
EnterCriticalSection (mutexp );
514
546
return 1 ;
515
547
#elif defined(NETWARE )
548
+ #ifdef USE_MPK
549
+ return kMutexLock (mutexp );
550
+ #else
516
551
return NXLock (mutexp );
552
+ #endif
517
553
#elif defined(GNUPTH )
518
554
return pth_mutex_acquire (mutexp , 0 , NULL );
519
555
#elif defined(PTHREADS )
@@ -540,7 +576,11 @@ TSRM_API int tsrm_mutex_unlock(MUTEX_T mutexp)
540
576
LeaveCriticalSection (mutexp );
541
577
return 1 ;
542
578
#elif defined(NETWARE )
579
+ #ifdef USE_MPK
580
+ return kMutexUnlock (mutexp );
581
+ #else
543
582
return NXUnlock (mutexp );
583
+ #endif
544
584
#elif defined(GNUPTH )
545
585
return pth_mutex_release (mutexp );
546
586
#elif defined(PTHREADS )
0 commit comments