From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Wolfgang Jenkner Newsgroups: gmane.emacs.devel Subject: Re: gfile-based file notifications are not immediate Date: Thu, 30 Oct 2014 20:12:54 +0100 Message-ID: <85a94dmfw6.fsf@iznogoud.viz> References: <87mw8jg9a1.fsf@secretsauce.net> <87y4s31czw.fsf@gmx.de> <6770871.AMhgTgWFL5@descartes> <87ppdbehjw.fsf@secretsauce.net> <87ioj3m6ah.fsf@gmx.de> <851tprvuvc.fsf@iznogoud.viz> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1414780073 491 80.91.229.3 (31 Oct 2014 18:27:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 31 Oct 2014 18:27:53 +0000 (UTC) Cc: =?utf-8?Q?R=C3=BCdiger?= Sonderfeld , emacs-devel@gnu.org, Stefan Monnier , Dima Kogan To: Michael Albinus Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Oct 31 19:27:47 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XkGvK-0004Pt-QP for ged-emacs-devel@m.gmane.org; Fri, 31 Oct 2014 19:27:47 +0100 Original-Received: from localhost ([::1]:40768 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XkGvK-0003bE-C1 for ged-emacs-devel@m.gmane.org; Fri, 31 Oct 2014 14:27:46 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50473) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XkE6g-0005NK-3D for emacs-devel@gnu.org; Fri, 31 Oct 2014 11:28:03 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xjwq7-0006q0-C7 for emacs-devel@gnu.org; Thu, 30 Oct 2014 17:01:08 -0400 Original-Received: from b2bfep14.mx.upcmail.net ([62.179.121.59]:52446) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xjwq7-0006pN-2d for emacs-devel@gnu.org; Thu, 30 Oct 2014 17:01:03 -0400 Original-Received: from edge12.upcmail.net ([192.168.13.82]) by b2bfep14-int.chello.at (InterMail vM.8.01.05.11 201-2260-151-128-20120928) with ESMTP id <20141030210059.ILWE6284.b2bfep14-int.chello.at@edge12.upcmail.net> for ; Thu, 30 Oct 2014 22:00:59 +0100 Original-Received: from iznogoud.viz ([91.119.107.147]) by edge12.upcmail.net with edge id 9Z0x1p00X3AqS0z0CZ0xed; Thu, 30 Oct 2014 22:00:59 +0100 X-SourceIP: 91.119.107.147 Original-Received: from wolfgang by iznogoud.viz with local (Exim 4.84 (FreeBSD)) (envelope-from ) id 1Xjwq1-000A6l-Ge; Thu, 30 Oct 2014 22:00:57 +0100 Mail-Followup-To: Michael Albinus , Stefan Monnier , Dima Kogan , =?utf-8?Q?R=C3=BCdiger?= Sonderfeld , emacs-devel@gnu.org User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/25.0.50 (berkeley-unix) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 62.179.121.59 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:176126 Archived-At: 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@ LIB_EXECINFO=@LIB_EXECINFO@ +LIB_INOTIFY=@LIB_INOTIFY@ + 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 (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---