s3: Improved support for GAMIN.
authorIra Cooper <samba@ira.wakeful.net>
Sun, 18 Apr 2010 13:02:23 +0000 (15:02 +0200)
committerVolker Lendecke <vl@samba.org>
Sun, 18 Apr 2010 13:12:41 +0000 (15:12 +0200)
Support the FAMNoExists API for gamin to reduce cpu use and problems when
using GAMIN as FAM for vfs_notify_fam.

source3/configure.in
source3/modules/vfs_notify_fam.c

index 26ec10ba5c305db065eee88cd366fcafbb8b263e..9a190cc872491560f3255b4e0d0f36d91f6615aa 100644 (file)
@@ -2644,18 +2644,19 @@ if test x$enable_fam != xno; then
         # On IRIX, libfam requires libC, but other FAM implementations
        # might not need it.
         AC_CHECK_LIB(fam, FAMOpen2,
-            [samba_cv_HAVE_LIBFAM=yes; SMB_FAM_LIBS="-lfam"],
-            [samba_cv_HAVE_LIBFAM=no])
+           [samba_cv_HAVE_LIBFAM=yes; SMB_FAM_LIBS="-lfam";
+           AC_DEFINE(HAVE_FAMOPEN2, 1, Define to 1 if there is support for FAMOpen2)],
+           [samba_cv_HAVE_LIBFAM=no])
 
         if test x"$samba_cv_HAVE_LIBFAM" = x"no" ; then
             samba_fam_xtra=-lC
             AC_CHECK_LIB_EXT(fam, samba_fam_xtra, FAMOpen2,
-                [samba_cv_HAVE_LIBFAM=yes; SMB_FAM_LIBS="-lfam -lC"],
-                [samba_cv_HAVE_LIBFAM=no])
+               [samba_cv_HAVE_LIBFAM=yes; SMB_FAM_LIBS="-lfam -lC";
+               AC_DEFINE(HAVE_FAMOPEN2, 1, Define to 1 if there is support for FAMOpen2)],
+               [samba_cv_HAVE_LIBFAM=no])
             unset samba_fam_xtra
         fi
     fi
-
     if test x"$samba_cv_HAVE_LIBFAM" = x"yes" ; then
         default_shared_modules="$default_shared_modules vfs_notify_fam"
         AC_TRY_COMPILE([#include <fam.h>],
@@ -2665,6 +2666,11 @@ if test x$enable_fam != xno; then
                     [])
     fi
 
+    if test x"$samba_cv_HAVE_LIBFAM" = x"yes" ; then
+       AC_CHECK_LIB(fam, FAMNoExists,
+           [AC_DEFINE(HAVE_FAMNOEXISTS, 1, Define to 1 if there is support for FAMNoExists)])
+    fi
+
     if test x$enable_fam = xyes && test x"$samba_cv_HAVE_LIBFAM" != xyes ; then
         AC_MSG_ERROR(FAM support requested but FAM library not available )
     fi
index 8f00c9207f2f43992fb78c6caa6c0710d448c166..652e785e0286b0598fd1433629afa25b379286e9 100644 (file)
@@ -79,12 +79,27 @@ static NTSTATUS fam_open_connection(FAMConnection *fam_conn,
        ZERO_STRUCTP(fam_conn);
        FAMCONNECTION_GETFD(fam_conn) = -1;
 
+
+#ifdef HAVE_FAMNOEXISTS
+       /* We should honor outside setting of the GAM_CLIENT_ID. */
+       setenv("GAM_CLIENT_ID","SAMBA",0);
+#endif
+
        if (asprintf(&name, "smbd (%lu)", (unsigned long)sys_getpid()) == -1) {
                DEBUG(0, ("No memory\n"));
                return NT_STATUS_NO_MEMORY;
        }
 
        res = FAMOpen2(fam_conn, name);
+
+#ifdef HAVE_FAMNOEXISTS
+       /*
+        * This reduces the chatter between GAMIN and samba making the pair
+        * much more reliable.
+        */
+       FAMNoExists(fam_conn);
+#endif
+
        SAFE_FREE(name);
 
        if (res < 0) {