From: Pekka Riikonen Date: Mon, 9 Jul 2001 18:52:16 +0000 (+0000) Subject: updates. X-Git-Tag: robodoc-323~88 X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=commitdiff_plain;h=d0e5ec965faf2017fbe888192521dc7bf6c31a09 updates. --- diff --git a/CHANGES b/CHANGES index 2bc6da63..d6cf2759 100644 --- a/CHANGES +++ b/CHANGES @@ -7,6 +7,9 @@ Mon Jul 9 18:28:34 EEST 2001 Pekka Riikonen * Completed the multi-thread support for SILC Scheduler in the lib/silcutil/silcschedule.c. + * Fixed the configure.in.pre to detect the pthread correctly + on various systems. + Mon Jul 9 13:40:03 EEST 2001 Pekka Riikonen * Added new function silc_schedule_wakeup that is used in diff --git a/Makefile.defines.pre b/Makefile.defines.pre index b795ed66..854a72ac 100644 --- a/Makefile.defines.pre +++ b/Makefile.defines.pre @@ -41,7 +41,7 @@ # # INCLUDE defines # -INCLUDES = $(ADD_INCLUDES) \ +INCLUDES = $(ADD_INCLUDES) $(SILC_CFLAGS) \ -I$(srcdir) -I$(top_srcdir) \ -I$(silc_top_srcdir) \ -I$(silc_top_srcdir)/lib/silccore \ diff --git a/Makefile.defines_int.pre b/Makefile.defines_int.pre index 446ca8f9..f0f79d69 100644 --- a/Makefile.defines_int.pre +++ b/Makefile.defines_int.pre @@ -32,6 +32,11 @@ silc_install_prefix=@prefix@ # SILC_COMMON_LIBS= @LIBS@ -L$(silc_top_srcdir)/lib -lsilc +# +# Common compilation flags +# +SILC_CFLAGS=@CFLAGS@ + # # Installation defines # diff --git a/acconfig.h.pre b/acconfig.h.pre index 2e40f0c7..1c6e64a8 100644 --- a/acconfig.h.pre +++ b/acconfig.h.pre @@ -71,6 +71,9 @@ #undef Rfclose #undef Rgethostbyname +/* POSIX thread checking */ +#undef SILC_HAVE_PTHREAD + /* Native WIN32 compilation (-mno-cygwin GCC option) under cygwin, though the code compiles with any native WIN32 compiler. */ #undef SILC_WIN32 diff --git a/configure.in.pre b/configure.in.pre index 9999270a..dca00154 100644 --- a/configure.in.pre +++ b/configure.in.pre @@ -67,7 +67,6 @@ AC_CHECK_HEADERS(netinet/in.h netinet/tcp.h netdb.h) AC_CHECK_HEADERS(pwd.h grp.h termcap.h paths.h) AC_CHECK_HEADERS(ncurses.h signal.h ctype.h regex.h) AC_CHECK_HEADERS(arpa/inet.h sys/mman.h limits.h) -AC_CHECK_HEADERS(pthread.h) # Data type checking AC_TYPE_SIGNAL @@ -532,7 +531,9 @@ AC_ARG_WITH(silcd-config-file, server [/etc/silc/silcd.conf]], [ AC_DEFINE_UNQUOTED(SILC_SERVER_CONFIG_FILE, "$withval") ]) +# # Native WIN32 compilation under cygwin +# AC_ARG_WITH(win32, [ --with-win32 Compile native WIN32 code (-mno-cygwin)], [ AC_DEFINE(SILC_WIN32) @@ -540,7 +541,9 @@ AC_ARG_WITH(win32, CFLAGS="-mno-cygwin $CFLAGS" LIBS="$LIBS -lwsock32" ]) +# # Debug checking +# AC_MSG_CHECKING(for enabled debugging) AC_ARG_ENABLE(debug, [ --enable-debug Enable debugging (warning: it is heavy!)], @@ -557,7 +560,21 @@ AC_ARG_ENABLE(debug, esac ], CFLAGS="-O2 -g $CFLAGS" AC_MSG_RESULT(no)) +# # Pthread checking +# +AC_CHECK_HEADERS(pthread.h, [ AC_DEFINE(SILC_HAVE_PTHREAD) ], + [ if test -f /usr/pkg/include/pthread.h ; then + AC_DEFINE(SILC_HAVE_PTHREAD) + AC_MSG_RESULT(Found pthread.h in /usr/pkg/include/) + CFLAGS="$CFLAGS -I/usr/pkg/include" + elif test -f /usr/contrib/include/pthread.h ; then + AC_DEFINE(SILC_HAVE_PTHREAD) + AC_MSG_RESULT(Found pthread.h in /usr/contrib/include/) + CFLAGS="$CFLAGS -I/usr/contrib/include" + fi + ]) + AC_ARG_ENABLE(threads, [ --disable-threads Do not compile with multi-thread support], [ case "${enableval}" in @@ -573,9 +590,42 @@ esac ], AC_DEFINE(SILC_THREADS) AM_CONDITIONAL(SILC_THREADS, test x$want_threads = xtrue) if test x$want_threads = xtrue; then - AC_TRY_COMPILE([#include ], - [pthread_attr_t attr; pthread_attr_init(&attr);], - LIBS="$LIBS -lpthread") + TMP_LIBS="$LIBS" + LIBS="-lpthread" + AC_TRY_LINK([#include ], + [pthread_attr_t attr; pthread_attr_init(&attr);], , + LIBS="-L/usr/pkg/lib -lpthread" + AC_TRY_LINK([#include ], + [pthread_attr_t attr; pthread_attr_init(&attr);], , + LIBS="-L/usr/contrib/lib -lpthread" + AC_TRY_LINK([#include ], + [pthread_attr_t attr; pthread_attr_init(&attr);], , LIBS="" + ))) + + CFLAGS="$CFLAGS -D_REENTRANT" + case $host in + *-aix*) + CFLAGS="$CFLAGS -D_THREAD_SAFE" + if test x"$GCC" = xyes; then + CFLAGS="$CFLAGS -mthreads" + fi + ;; + *-freebsd2.2*) + CFLAGS="$CFLAGS -D_THREAD_SAFE" + ;; + *-sysv5uw7*) # UnixWare 7 + if test "$GCC" != "yes"; then + CFLAGS="$CFLAGS -Kthread" + else + CFLAGS="$CFLAGS -pthread" + fi + ;; + *-dg-dgux*) # DG/UX + CFLAGS="$CFLAGS -D_POSIX4A_DRAFT10_SOURCE" + ;; + esac + + LIBS="$TMP_LIBS $LIBS" fi # diff --git a/includes/silcincludes.h b/includes/silcincludes.h index 6ffb7186..4ce05d26 100644 --- a/includes/silcincludes.h +++ b/includes/silcincludes.h @@ -130,7 +130,7 @@ #include #endif -#ifdef HAVE_PTHREAD_H +#ifdef SILC_HAVE_PTHREAD #include #endif diff --git a/lib/silcutil/silcschedule.c b/lib/silcutil/silcschedule.c index ee1063d4..046cfa30 100644 --- a/lib/silcutil/silcschedule.c +++ b/lib/silcutil/silcschedule.c @@ -613,6 +613,8 @@ bool silc_schedule_one(SilcSchedule schedule, int timeout_usecs) if ((!schedule->fd_queue && !schedule->timeout_queue && !schedule->generic_queue) || schedule->valid == FALSE) { SILC_LOG_DEBUG(("Scheduler not valid anymore, exiting")); + if (!schedule->is_locked) + silc_mutex_unlock(schedule->lock); return FALSE; } @@ -632,8 +634,11 @@ bool silc_schedule_one(SilcSchedule schedule, int timeout_usecs) tasks. The silc_select() listens to these file descriptors. */ SILC_SCHEDULE_SELECT_TASKS; - if (schedule->max_fd == -1 && !schedule->timeout) + if (schedule->max_fd == -1 && !schedule->timeout) { + if (!schedule->is_locked) + silc_mutex_unlock(schedule->lock); return FALSE; + } if (schedule->timeout) { SILC_LOG_DEBUG(("timeout: sec=%d, usec=%d", schedule->timeout->tv_sec,