emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gfile-based file notifications are not immediate


From: Wolfgang Jenkner
Subject: Re: gfile-based file notifications are not immediate
Date: Thu, 30 Oct 2014 20:12:54 +0100
User-agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/25.0.50 (berkeley-unix)

On Wed, Oct 29 2014, Wolfgang Jenkner wrote:

> There's an active project to implement inotify for *BSD
>
> https://github.com/dmatveev/libinotify-kqueue

Below is an updated patch for using this library.

I tried it on FreeBSD 10-STABLE by configuring emacs (trunk HEAD at
c0696d2) like this

./configure --with-x-toolkit=no --without-gsettings --without-rsvg 
--with-file-notification=inotify

(which on my system is enough to make sure that emacs is not linked with
libglib-2.0).

Previously, I had installed libinotify from the current HEAD on the
master branch (by adapting the existing devel/libinotify port, see
below).

After building emacs, I found that "gmake check" barfed, so I just
loaded test/automated/inotify-test.el and
test/automated/file-notify-tests.el and used ert-run-tests-interactively
to run the tests in those files.

All those test succeeded with `Ran 1 tests, 1 results were as expected'
except that the first test for remote files gave `Ran 1 tests, 0 results
were as expected, 1 skipped', so I didn't try the rest of them.

I can also replicate the behaviour Dima described in bug#18880.

I've also randomly played with file notifications and so far there were
no adverse effects on this emacs instance in which I am writing this.

There are two patches here:

The first patch is meant for FreeBSD (and, perhaps, DFly) people who
want to build the current libinotify from ports (and it has to be
applied in the devel/libinotify subdirectory of the ports tree).

The second patch is for emacs.  As I said in the previous mail, it
contains a more or less bogus work-around for the currently missing
inotify_init1().

--8<---------------cut here---------------start------------->8---
Index: Makefile
===================================================================
--- Makefile    (revision 371635)
+++ Makefile    (working copy)
@@ -13,7 +13,8 @@
 USE_GITHUB=    yes
 GH_ACCOUNT=    dmatveev
 GH_PROJECT=    libinotify-kqueue
-GH_COMMIT=     d775062
+#GH_COMMIT=    d775062
+GH_COMMIT=     953b095
 GH_TAGNAME=    ${GH_COMMIT}
 
 USE_LDCONFIG=  yes
Index: distinfo
===================================================================
--- distinfo    (revision 371635)
+++ distinfo    (working copy)
@@ -1,2 +1,2 @@
-SHA256 (libinotify-20140622.tar.gz) = 
512ca9342ab44ab1338c46baab596bd510ba9631d8ecb3b64ef8a89aa1b90d19
-SIZE (libinotify-20140622.tar.gz) = 33447
+SHA256 (libinotify-20140622.tar.gz) = 
89a5c7796f46dd31501941617687ef6cb0705011e0a723433b094ddbc0c9bedb
+SIZE (libinotify-20140622.tar.gz) = 34586
--8<---------------cut here---------------end--------------->8---

--8<---------------cut here---------------start------------->8---
Subject: [PATCH] Tentative libinotify support.

---
 configure.ac    | 20 ++++++++++++++------
 src/Makefile.in |  4 +++-
 src/inotify.c   |  7 +++++++
 3 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/configure.ac b/configure.ac
index cb42ed6..1665440 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2620,19 +2620,27 @@ case $with_file_notification,$NOTIFY_OBJ in
     fi ;;
 esac
 
-dnl inotify is only available on GNU/Linux.
+dnl inotify is available on GNU/Linux or, through libinotify, on *BSD.
+LIB_INOTIFY=
 case $with_file_notification,$NOTIFY_OBJ in
   inotify, | yes,)
     AC_CHECK_HEADER(sys/inotify.h)
     if test "$ac_cv_header_sys_inotify_h" = yes ; then
-       AC_CHECK_FUNC(inotify_init1)
-       if test "$ac_cv_func_inotify_init1" = yes; then
-         AC_DEFINE(HAVE_INOTIFY, 1, [Define to 1 to use inotify.])
-         NOTIFY_OBJ=inotify.o
-         NOTIFY_SUMMARY="yes -lglibc (inotify)"
+       AC_SEARCH_LIBS(inotify_init, inotify)
+       if test "$ac_cv_search_inotify_init" != no; then
+         AC_CHECK_FUNCS(inotify_init1 inotify_init)
+         if test "$ac_cv_func_inotify_init" = yes; then
+            AC_DEFINE(HAVE_INOTIFY, 1, [Define to 1 to use inotify.])
+            NOTIFY_OBJ=inotify.o
+            if test "$ac_cv_search_inotify_init" != "none required"; then
+               LIB_INOTIFY="$ac_cv_search_inotify_init"
+            fi
+            NOTIFY_SUMMARY="yes $LIB_INOTIFY (inotify)"
+         fi
        fi
     fi ;;
 esac
+AC_SUBST(LIB_INOTIFY)
 
 case $with_file_notification,$NOTIFY_OBJ in
   yes,* | no,* | *,?*) ;;
diff --git a/src/Makefile.in b/src/Makefile.in
index 270119e..34db667 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -153,6 +153,8 @@ DBUS_OBJ = @DBUS_OBJ@
 
 address@hidden@
 
address@hidden@
+
 SETTINGS_CFLAGS = @SETTINGS_CFLAGS@
 SETTINGS_LIBS = @SETTINGS_LIBS@
 
@@ -429,7 +431,7 @@ LIBES = $(LIBS) $(W32_LIBS) $(LIBS_GNUSTEP) $(LIBX_BASE) 
$(LIBIMAGE) \
    $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \
    $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \
    $(LIBGNUTLS_LIBS) $(LIB_PTHREAD) \
-   $(GFILENOTIFY_LIBS) $(LIB_MATH) $(LIBZ)
+   $(GFILENOTIFY_LIBS) $(LIB_INOTIFY) $(LIB_MATH) $(LIBZ)
 
 all: emacs$(EXEEXT) $(OTHER_FILES)
 .PHONY: all
diff --git a/src/inotify.c b/src/inotify.c
index c55b130..e321a6d 100644
--- a/src/inotify.c
+++ b/src/inotify.c
@@ -333,7 +333,14 @@ is managed internally and there is no corresponding 
inotify_init.  Use
 
   if (inotifyfd < 0)
     {
+#if HAVE_INOTIFY_INIT1
       inotifyfd = inotify_init1 (IN_NONBLOCK|IN_CLOEXEC);
+#else /* I have no idea what I'm doing here. */
+      inotifyfd = inotify_init ();
+#include <fcntl.h>
+      fcntl (inotifyfd, F_SETFL, O_NONBLOCK);
+      fcntl (inotifyfd, F_SETFD, FD_CLOEXEC);
+#endif
       if (inotifyfd < 0)
        xsignal1
          (Qfile_notify_error,
-- 
2.1.2

--8<---------------cut here---------------end--------------->8---



reply via email to

[Prev in Thread] Current Thread [Next in Thread]