[xml] fix for the ./testThreads hang on HP-UX



the code in threads.c is not initializing the cv condition variable
correctly when an xmlRMutex is allocated. 

per the HP-UX 11 manpage for pthread_cond_wait:

 The condition variabled denoted by cond must have been dynamically
 initialized by a call to pthread_cond_init() or statically initialized
 with the macro PTHREAD_COND_INITIALIZER.

and this was not being done. I suppose that on other platforms the code
was simply getting lucky - perhaps malloc was always zeroing memory or
somesuch. anyhow, here is the diff against the 2.4.23 bits:

$ diff -c threads.c.orig threads.c
*** threads.c.orig      Thu Jul 25 16:25:57 2002
--- threads.c   Thu Jul 25 16:38:45 2002
***************
*** 192,197 ****
--- 192,198 ----
          return (NULL);
  #ifdef HAVE_PTHREAD_H
      pthread_mutex_init(&tok->lock, NULL);
+     pthread_cond_init(&tok->cv,NULL);
      tok->held = 0;
      tok->waiters = 0;
  #elif defined HAVE_WIN32_THREADS


rick jones

btw, it would probably be a good idea to check the return codes from
pthread_mutex_init() and pthread_cond_init()...



-- 
Wisdom Teeth are impacted, people are affected by the effects of events.
these opinions are mine, all mine; HP might not want them anyway... :)
feel free to post, OR email to raj in cup.hp.com  but NOT BOTH...



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]