Commit 842e8fca authored by monty@hundin.mysql.fi's avatar monty@hundin.mysql.fi
Browse files

Backported pthread_mutex_trylock code from MySQL 4.0 to fix problem on HPUX.

Removed Heikki's patch for handling this.
parent a500c7de
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -849,8 +849,8 @@ case $SYSTEM_TYPE in
    ;;
  *hpux10.20*)
    echo "Enabling workarounds for hpux 10.20"
    CFLAGS="$CFLAGS -DHAVE_BROKEN_SNPRINTF -DSIGNALS_DONT_BREAK_READ -DDO_NOT_REMOVE_THREAD_WRAPPERS -DHPUX -DSIGNAL_WITH_VIO_CLOSE -DHAVE_BROKEN_PTHREAD_COND_TIMEDWAIT -DPTHREAD_MUTEX_TRYLOCK_INVERTED_RET_VAL"
    CXXFLAGS="$CXXFLAGS -DHAVE_BROKEN_SNPRINTF -D_INCLUDE_LONGLONG -DSIGNALS_DONT_BREAK_READ -DDO_NOT_REMOVE_THREAD_WRAPPERS -DHPUX -DSIGNAL_WITH_VIO_CLOSE -DHAVE_BROKEN_PTHREAD_COND_TIMEDWAIT -DPTHREAD_MUTEX_TRYLOCK_INVERTED_RET_VAL"
    CFLAGS="$CFLAGS -DHAVE_BROKEN_SNPRINTF -DSIGNALS_DONT_BREAK_READ -DDO_NOT_REMOVE_THREAD_WRAPPERS -DHPUX -DSIGNAL_WITH_VIO_CLOSE -DHAVE_BROKEN_PTHREAD_COND_TIMEDWAIT"
    CXXFLAGS="$CXXFLAGS -DHAVE_BROKEN_SNPRINTF -D_INCLUDE_LONGLONG -DSIGNALS_DONT_BREAK_READ -DDO_NOT_REMOVE_THREAD_WRAPPERS -DHPUX -DSIGNAL_WITH_VIO_CLOSE -DHAVE_BROKEN_PTHREAD_COND_TIMEDWAIT"
    if test "$with_named_thread" = "no"
    then 
      echo "Using --with-named-thread=-lpthread"
+10 −7
Original line number Diff line number Diff line
@@ -428,6 +428,16 @@ struct tm *localtime_r(const time_t *clock, struct tm *res);

#endif /* defined(__WIN__) */

#if defined(HPUX) && !defined(DONT_REMAP_PTHREAD_FUNCTIONS)
#undef pthread_cond_timedwait
#undef pthread_mutex_trylock
#define pthread_cond_timedwait(a,b,c) my_pthread_cond_timedwait((a),(b),(c))
#define pthread_mutex_trylock(a) my_pthread_mutex_trylock((a))
int my_pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
			      struct timespec *abstime);
int my_pthread_mutex_trylock(pthread_mutex_t *mutex);
#endif

	/* safe_mutex adds checking to mutex for easier debugging */

typedef struct st_safe_mutex_t
@@ -464,14 +474,7 @@ int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp,
#define pthread_mutex_destroy(A) safe_mutex_destroy((A),__FILE__,__LINE__)
#define pthread_cond_wait(A,B) safe_cond_wait((A),(B),__FILE__,__LINE__)
#define pthread_cond_timedwait(A,B,C) safe_cond_timedwait((A),(B),(C),__FILE__,__LINE__)
#ifdef PTHREAD_MUTEX_TRYLOCK_INVERTED_RET_VAL
  /* In HP-UX-10.20 and other old Posix 1003.4a Draft 4 implementations
     pthread_mutex_trylock returns 1 on success, not 0 like
     pthread_mutex_lock */
#define pthread_mutex_trylock(A) (1 - pthread_mutex_lock(A))
#else
#define pthread_mutex_trylock(A) pthread_mutex_lock(A)
#endif
#define pthread_mutex_t safe_mutex_t
#endif /* SAFE_MUTEX */

+21 −2
Original line number Diff line number Diff line
@@ -409,7 +409,7 @@ int my_pthread_cond_init(pthread_cond_t *mp, const pthread_condattr_t *attr)

/* Change functions on HP to work according to POSIX */

#ifdef HAVE_BROKEN_PTHREAD_COND_TIMEDWAIT
#if defined(HPUX) || defined(HAVE_BROKEN_PTHREAD_COND_TIMEDWAIT)
#undef pthread_cond_timedwait

int my_pthread_cond_timedwait(pthread_cond_t *cond,
@@ -426,7 +426,26 @@ int my_pthread_cond_timedwait(pthread_cond_t *cond,
    error= ETIMEDOUT;
  return error;
}
#endif /* HAVE_BROKEN_PTHREAD_COND_TIMEDWAIT */
#endif


#ifdef HPUX
/*
  In HP-UX-10.20 and other old Posix 1003.4a Draft 4 implementations
  pthread_mutex_trylock returns 1 on success, not 0 like
  pthread_mutex_lock
*/

int my_pthread_mutex_trylock(pthread_mutex_t *mutex)
{
  int error=pthread_mutex_trylock(mutex);
  if (error == 1)			/* Safety if the lib is fixed */
    return 0;				/* Mutex was locked */
  if (error == -1)			/* Safety if the lib is fixed */
    error=errno;
   return error;
}
#endif


/* Some help functions */