updates.
authorPekka Riikonen <priikone@silcnet.org>
Mon, 9 Jul 2001 18:52:16 +0000 (18:52 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Mon, 9 Jul 2001 18:52:16 +0000 (18:52 +0000)
CHANGES
Makefile.defines.pre
Makefile.defines_int.pre
acconfig.h.pre
configure.in.pre
includes/silcincludes.h
lib/silcutil/silcschedule.c

diff --git a/CHANGES b/CHANGES
index 2bc6da63b28c4fc9ec373816336ea1f926aa9757..d6cf2759b3a2095ceeb0b1da2f7861f2de1f04e7 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -7,6 +7,9 @@ Mon Jul  9 18:28:34 EEST 2001  Pekka Riikonen <priikone@silcnet.org>
        * 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 <priikone@silcnet.org>
 
        * Added new function silc_schedule_wakeup that is used in
index b795ed6600dceca5505d49af5fc2b534d665ba57..854a72ac252e7c28289732ec4ed5dd6db148e83e 100644 (file)
@@ -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 \
index 446ca8f9733d1e822e765a224f506f57e235033c..f0f79d699c2d36b2ec026057e1bb7c998b87a780 100644 (file)
@@ -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
 #
index 2e40f0c7e6154f9c9dc9c65bcbaa63fc3ad8f381..1c6e64a881ed9ce75ac92d369f70c055e2a1ba96 100644 (file)
@@ -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
index 9999270a50e55ec5f0eee1de28375e3d5ecafe31..dca00154a33a90b1893c6b67ac2f13b8fdb8fd8e 100644 (file)
@@ -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.h>],
-                [pthread_attr_t attr; pthread_attr_init(&attr);],
-                LIBS="$LIBS -lpthread")
+  TMP_LIBS="$LIBS"
+  LIBS="-lpthread"
+  AC_TRY_LINK([#include <pthread.h>],
+             [pthread_attr_t attr; pthread_attr_init(&attr);], ,
+  LIBS="-L/usr/pkg/lib -lpthread"
+  AC_TRY_LINK([#include <pthread.h>],
+             [pthread_attr_t attr; pthread_attr_init(&attr);], ,
+  LIBS="-L/usr/contrib/lib -lpthread"
+  AC_TRY_LINK([#include <pthread.h>],
+             [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
 
 #
index 6ffb7186c281f520de3dbffad0a86f34781aa05b..4ce05d26e2f11b8827b4f6962d4d5b4c2e238b12 100644 (file)
 #include <regex.h>
 #endif
 
-#ifdef HAVE_PTHREAD_H
+#ifdef SILC_HAVE_PTHREAD
 #include <pthread.h>
 #endif
 
index ee1063d42917b329bfe4306bcea7cd6b0ee7e3bd..046cfa3077aa88a9cbec040dbcbaaf114650f7c3 100644 (file)
@@ -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,