svn commit: samba r16214 - in trunk/source: .
jpeach at samba.org
jpeach at samba.org
Wed Jun 14 00:57:15 GMT 2006
Author: jpeach
Date: 2006-06-14 00:57:11 +0000 (Wed, 14 Jun 2006)
New Revision: 16214
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=16214
Log:
As discussed in the thread entitled "Failed to setup RT_SIGNAL_NOTIFY
handler", linking with libpthread can cause sigaction to fail when
setting handlers for the realtime signals used for change notification
an oplocks on Linux. Unfortunately, we often pull in libpthread as a
side-effect of linking with librt, which can happen when we configure
with --with-aio-support or --with-profiling-data. See the thread
entitled "check for CLOCK_MONOTONIC" for more on this.
This implements the algorithm agreed to in the latter thread, which goes
like this:
if we have a feature that requires realtime signals
check if each realtime signal works
if the corresponding signal fails
if libpthread
emit blame libpthread message
fail
else
emit message
fail
else
if libpthread
emit libpthread warning
succeed
This change should go to 3_0 after the 3.0.23 release.
Modified:
trunk/source/aclocal.m4
trunk/source/configure.in
Changeset:
Modified: trunk/source/aclocal.m4
===================================================================
--- trunk/source/aclocal.m4 2006-06-14 00:37:52 UTC (rev 16213)
+++ trunk/source/aclocal.m4 2006-06-14 00:57:11 UTC (rev 16214)
@@ -981,3 +981,97 @@
AC_MSG_RESULT(no)
])
])
+
+dnl SMB_IF_RTSIGNAL_BUG([actions if true],
+dnl [actions if false],
+dnl [actions if cross compiling])
+dnl Test whether we can call sigaction with RT_SIGNAL_NOTIFY and
+dnl RT_SIGNAL_LEASE (also RT_SIGNAL_AIO for good measure, though
+dnl I don't believe that triggers any bug.
+dnl
+dnl See the samba-technical thread titled "Failed to setup
+dnl RT_SIGNAL_NOTIFY handler" for details on the bug in question.
+AC_DEFUN([SMB_IF_RTSIGNAL_BUG],
+[
+ rt_signal_notify_works=yes
+ rt_signal_lease_works=yes
+ rt_signal_aio_works=yes
+
+ AC_MSG_CHECKING(if sigaction works with realtime signals)
+ AC_TRY_RUN(
+ [
+#include <sys/types.h>
+#include <fcntl.h>
+#include <signal.h>
+
+/* from smbd/notify_kernel.c */
+#ifndef RT_SIGNAL_NOTIFY
+#define RT_SIGNAL_NOTIFY (SIGRTMIN+2)
+#endif
+
+/* from smbd/aio.c */
+#ifndef RT_SIGNAL_AIO
+#define RT_SIGNAL_AIO (SIGRTMIN+3)
+#endif
+
+/* from smbd/oplock_linux.c */
+#ifndef RT_SIGNAL_LEASE
+#define RT_SIGNAL_LEASE (SIGRTMIN+1)
+#endif
+
+static void signal_handler(int sig, siginfo_t *info, void *unused)
+{
+ int do_nothing = 0;
+}
+
+int main(void)
+{
+ int result = 0;
+ struct sigaction act = {0};
+
+ act.sa_sigaction = signal_handler;
+ act.sa_flags = SA_SIGINFO;
+ sigemptyset( &act.sa_mask );
+
+ if (sigaction(RT_SIGNAL_LEASE, &act, 0) != 0) {
+ /* Failed to setup RT_SIGNAL_LEASE handler */
+ result += 1;
+ }
+
+ if (sigaction(RT_SIGNAL_NOTIFY, &act, 0) != 0) {
+ /* Failed to setup RT_SIGNAL_NOTIFY handler */
+ result += 10;
+ }
+
+ if (sigaction(RT_SIGNAL_AIO, &act, 0) != 0) {
+ /* Failed to setup RT_SIGNAL_AIO handler */
+ result += 100;
+ }
+
+ /* zero on success */
+ return result;
+}
+ ],
+ [
+ AC_MSG_RESULT(yes)
+ $2
+ ],
+ [
+ AC_MSG_RESULT(no)
+ case "$ac_status" in
+ 1|11|101|111) rt_signal_lease_ok=no ;;
+ esac
+ case "$ac_status" in
+ 10|11|110|111) rt_signal_notify_ok=no ;;
+ esac
+ case "$ac_status" in
+ 100|110|101|111) rt_signal_aio_ok=no ;;
+ esac
+ $2
+ ],
+ [
+ AC_MSG_RESULT(cross)
+ $3
+ ])
+])
+
Modified: trunk/source/configure.in
===================================================================
--- trunk/source/configure.in 2006-06-14 00:37:52 UTC (rev 16213)
+++ trunk/source/configure.in 2006-06-14 00:57:11 UTC (rev 16214)
@@ -2054,15 +2054,11 @@
AC_LIBTESTFUNC(rt, clock_gettime,
[
- SMB_IS_LIBPTHREAD_LINKED(
- [ SMB_REMOVELIB(rt) ],
- [
- AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
- [Whether clock_gettime is available])
- SMB_CHECK_CLOCK_ID(CLOCK_MONOTONIC)
- SMB_CHECK_CLOCK_ID(CLOCK_PROCESS_CPUTIME_ID)
- SMB_CHECK_CLOCK_ID(CLOCK_REALTIME)
- ])
+ AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
+ [Whether clock_gettime is available])
+ SMB_CHECK_CLOCK_ID(CLOCK_MONOTONIC)
+ SMB_CHECK_CLOCK_ID(CLOCK_PROCESS_CPUTIME_ID)
+ SMB_CHECK_CLOCK_ID(CLOCK_REALTIME)
])
fi
@@ -5575,6 +5571,78 @@
fi
#################################################
+# check for bad librt/libpthread interactions
+
+if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_LINUX" = x"yes" -o \
+ x"$samba_cv_HAVE_KERNEL_CHANGE_NOTIFY" = x"yes" -o \
+ x"$samba_cv_HAVE_AIO64" = x"yes" -o \
+ x"$samba_cv_HAVE_AIO" = x"yes" ; then
+
+SMB_IF_RTSIGNAL_BUG(
+ [
+ # Have RT_SIGNAL bug, need to check whether the problem will
+ # affect anything we have configured.
+
+ rt_do_error=no
+ if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_LINUX" = x"yes"; then
+ if test x"$rt_signal_lease_ok" = x"no" ; then
+ rt_do_error=yes
+ fi
+ fi
+
+ if test x"$samba_cv_HAVE_KERNEL_CHANGE_NOTIFY" = x"yes"; then
+ if test x"$rt_signal_notify_ok" = x"no" ; then
+ rt_do_error=yes
+ fi
+ fi
+
+ if test x"$samba_cv_HAVE_AIO64" = x"yes" -o \
+ x"$samba_cv_HAVE_AIO" = x"yes" ; then
+ if test x"$rt_signal_aio_ok" = x"no" ; then
+ rt_do_error=yes
+ fi
+ fi
+
+ if test x"$rt_do_error" = x"yes" ; then
+ SMB_IS_LIBPTHREAD_LINKED(
+ [
+ cat<<MSG
+
+*** On this platforms, linking Samba against pthreads causes problems
+*** with the oplock and change notification mechanisms. You may be
+*** using pthreads as a side-effect of using the --with-aio-support
+*** or --with-profiling-data options. Please remove these and try again.
+
+MSG
+ ],
+ [
+ cat<<MSG
+
+*** On this platform, the oplock and change notification mechanisms do not
+*** appear to work. Please report this problem to samba-technical at samba.org
+*** and attach the config.log file from this directory.
+
+MSG
+ ])
+ AC_MSG_ERROR(unable to use realtime signals on this platform)
+ fi
+ ],
+ [
+ # no RT_SIGNAL bug, we are golden
+ SMB_IS_LIBPTHREAD_LINKED(
+ [
+ AC_MSG_WARN(using libpthreads - this may degrade performance)
+ ])
+
+ ],
+ [
+ # cross compiling, I hope you know what you are doing
+ true
+ ])
+
+fi
+
+#################################################
# Display summary of libraries detected
AC_MSG_RESULT([Using libraries:])
More information about the samba-cvs
mailing list