From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#26973: 26.0.50; sleep-for behavior changes with global-auto-revert-mode enabled Date: Fri, 26 May 2017 11:06:38 -0700 Organization: UCLA Computer Science Department Message-ID: <52366f47-5bf1-8eaa-f605-44d0def010aa@cs.ucla.edu> References: <707f822e-5034-4fdc-c7a4-96eb40454b93@yandex.ru> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------F39056AE57A8528BC4C05647" X-Trace: blaine.gmane.org 1495822032 16025 195.159.176.226 (26 May 2017 18:07:12 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 26 May 2017 18:07:12 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 Cc: 26973@debbugs.gnu.org, Michael Albinus , Dmitry Gutov To: Andreas Politz Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri May 26 20:07:08 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dEJdj-00043d-LX for geb-bug-gnu-emacs@m.gmane.org; Fri, 26 May 2017 20:07:07 +0200 Original-Received: from localhost ([::1]:37824 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dEJdp-00019s-0r for geb-bug-gnu-emacs@m.gmane.org; Fri, 26 May 2017 14:07:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56560) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dEJdi-00019b-Cc for bug-gnu-emacs@gnu.org; Fri, 26 May 2017 14:07:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dEJdf-0001qR-6h for bug-gnu-emacs@gnu.org; Fri, 26 May 2017 14:07:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:36871) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dEJdf-0001qI-0E for bug-gnu-emacs@gnu.org; Fri, 26 May 2017 14:07:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dEJde-0002bZ-KN for bug-gnu-emacs@gnu.org; Fri, 26 May 2017 14:07:02 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <707f822e-5034-4fdc-c7a4-96eb40454b93@yandex.ru> Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 26 May 2017 18:07:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 26973 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 26973-submit@debbugs.gnu.org id=B26973.14958220099995 (code B ref 26973); Fri, 26 May 2017 18:07:02 +0000 Original-Received: (at 26973) by debbugs.gnu.org; 26 May 2017 18:06:49 +0000 Original-Received: from localhost ([127.0.0.1]:39548 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dEJdR-0002b8-8d for submit@debbugs.gnu.org; Fri, 26 May 2017 14:06:49 -0400 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:50336) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dEJdP-0002av-5i for 26973@debbugs.gnu.org; Fri, 26 May 2017 14:06:48 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 497191600B9; Fri, 26 May 2017 11:06:41 -0700 (PDT) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id rr0QCDQS6i0I; Fri, 26 May 2017 11:06:40 -0700 (PDT) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id E69FC1600C4; Fri, 26 May 2017 11:06:39 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id kEr1c-wsHC2i; Fri, 26 May 2017 11:06:39 -0700 (PDT) Original-Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 4D1941600B9; Fri, 26 May 2017 11:06:39 -0700 (PDT) Content-Language: en-US X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:132892 Archived-At: This is a multi-part message in MIME format. --------------F39056AE57A8528BC4C05647 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit > the event flags used are to[o] promiscuous and that this > prevents other processes from reading. Removing ACCESS, OPEN and > CLOSE events appears to rectify the situation. This means that a later call to inotify-add-watch that lacks IN_OPEN will disable an already-existing watch that specifies IN_OPEN, right? That doesn't sound right. I reviewed the inotify.c patches made since March and spotted what appear to be some problems related to this. What do you think of the attached patches? The first patch doesn't change behavior; it merely makes the later patches easier to write. The second patch restores onlydir (it appears to have been removed by mistake). The third patch uses IN_MASK_ADD instead of a promiscuous mask. --------------F39056AE57A8528BC4C05647 Content-Type: text/x-patch; name="0001-Simplify-computation-of-inotify-mask.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Simplify-computation-of-inotify-mask.patch" >From 46eb61f91160f51e2c16c14b327a2d2f8145d186 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 26 May 2017 09:37:44 -0700 Subject: [PATCH 1/3] Simplify computation of inotify mask * src/inotify.c (add_watch): Accept uint32_t imask instead of Lisp_Object aspect. Caller changed. (Finotify_add_watch): Use aspect_to_inotifymask earlier, to simplify the code. --- src/inotify.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/inotify.c b/src/inotify.c index 1165293..bcf30ad 100644 --- a/src/inotify.c +++ b/src/inotify.c @@ -215,16 +215,15 @@ inotifyevent_to_event (Lisp_Object watch, struct inotify_event const *ev) } /* Add a new watch to watch-descriptor WD watching FILENAME and using - CALLBACK. Returns a cons (DESCRIPTOR . ID) uniquely identifying the - new watch. */ + IMASK and CALLBACK. Return a cons (DESCRIPTOR . ID) uniquely + identifying the new watch. */ static Lisp_Object add_watch (int wd, Lisp_Object filename, - Lisp_Object aspect, Lisp_Object callback) + uint32_t imask, Lisp_Object callback) { Lisp_Object descriptor = INTEGER_TO_CONS (wd); Lisp_Object tail = assoc_no_quit (descriptor, watch_list); Lisp_Object watch, watch_id; - uint32_t imask = aspect_to_inotifymask (aspect); Lisp_Object mask = INTEGER_TO_CONS (imask); EMACS_INT id = 0; @@ -436,12 +435,10 @@ IN_ONLYDIR */) (Lisp_Object filename, Lisp_Object aspect, Lisp_Object callback) { Lisp_Object encoded_file_name; - bool dont_follow = (CONSP (aspect) - ? ! NILP (Fmemq (Qdont_follow, aspect)) - : EQ (Qdont_follow, aspect)); int wd = -1; + uint32_t imask = aspect_to_inotifymask (aspect); uint32_t mask = (INOTIFY_DEFAULT_MASK - | (dont_follow ? IN_DONT_FOLLOW : 0)); + | (imask & IN_DONT_FOLLOW)); CHECK_STRING (filename); @@ -459,7 +456,7 @@ IN_ONLYDIR */) if (wd < 0) report_file_notify_error ("Could not add watch for file", filename); - return add_watch (wd, filename, aspect, callback); + return add_watch (wd, filename, imask, callback); } static bool -- 2.9.4 --------------F39056AE57A8528BC4C05647 Content-Type: text/x-patch; name="0002-Restore-inotify-onlydir-support.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0002-Restore-inotify-onlydir-support.patch" >From d8ada0da7041e524b97c4354facd8803716d92bf Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 26 May 2017 09:50:56 -0700 Subject: [PATCH 2/3] Restore inotify onlydir support There was no need to remove it in the 2017-03-26 inotify change, as it is like IN_DONT_FOLLOW and does not affect other watchers for the same file. * src/inotify.c (symbol_to_inotifymask, Finotify_add_watch) (syms_of_inotify): Bring back onlydir. --- src/inotify.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/inotify.c b/src/inotify.c index bcf30ad..b3e0728 100644 --- a/src/inotify.c +++ b/src/inotify.c @@ -72,10 +72,6 @@ static int inotifyfd = -1; IN_EXCL_UNLINK IN_MASK_ADD IN_ONESHOT - IN_ONLYDIR - - FIXME: Explain why IN_ONLYDIR is in the list, as it seems to be - in the same category as IN_DONT_FOLLOW which is allowed. Each element of this list is of the form (DESCRIPTOR . WATCHES) where no two DESCRIPTOR values are the same. DESCRIPTOR represents @@ -162,6 +158,8 @@ symbol_to_inotifymask (Lisp_Object symb) else if (EQ (symb, Qdont_follow)) return IN_DONT_FOLLOW; + else if (EQ (symb, Qonlydir)) + return IN_ONLYDIR; else if (EQ (symb, Qt) || EQ (symb, Qall_events)) return IN_ALL_EVENTS; @@ -397,9 +395,11 @@ all-events or t move close -The following symbols can also be added to a list of aspects: +ASPECT can also contain the following symbols, which control whether +the watch descriptor will be created: dont-follow +onlydir Watching a directory is not recursive. CALLBACK is passed a single argument EVENT which contains an event structure of the format @@ -430,15 +430,14 @@ shared across different callers. IN_EXCL_UNLINK IN_MASK_ADD -IN_ONESHOT -IN_ONLYDIR */) +IN_ONESHOT */) (Lisp_Object filename, Lisp_Object aspect, Lisp_Object callback) { Lisp_Object encoded_file_name; int wd = -1; uint32_t imask = aspect_to_inotifymask (aspect); uint32_t mask = (INOTIFY_DEFAULT_MASK - | (imask & IN_DONT_FOLLOW)); + | (imask & (IN_DONT_FOLLOW | IN_ONLYDIR))); CHECK_STRING (filename); @@ -548,6 +547,7 @@ syms_of_inotify (void) DEFSYM (Qclose, "close"); /* IN_CLOSE */ DEFSYM (Qdont_follow, "dont-follow"); /* IN_DONT_FOLLOW */ + DEFSYM (Qonlydir, "onlydir"); /* IN_ONLYDIR */ DEFSYM (Qignored, "ignored"); /* IN_IGNORED */ DEFSYM (Qisdir, "isdir"); /* IN_ISDIR */ -- 2.9.4 --------------F39056AE57A8528BC4C05647 Content-Type: text/x-patch; name="0003-Depromiscuify-inotify-with-IN_MASK_ADD.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0003-Depromiscuify-inotify-with-IN_MASK_ADD.patch" >From 0c581863f4b1f3ef31397357dd454fe68416e645 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 26 May 2017 10:53:02 -0700 Subject: [PATCH 3/3] Depromiscuify inotify with IN_MASK_ADD Use IN_MASK_ADD instead of using a no-longer-promiscuous-enough mask. Without this fix, a later watch that omits IN_OPEN disables an earlier watch that uses IN_OPEN (Bug#26973). * src/inotify.c (INOTIFY_DEFAULT_MASK): Remove. (Finotify_add_watch): Use IN_MASK_ADD instead. --- src/inotify.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/src/inotify.c b/src/inotify.c index b3e0728..3d5d3d2 100644 --- a/src/inotify.c +++ b/src/inotify.c @@ -42,21 +42,6 @@ along with GNU Emacs. If not, see . */ # define IN_ONLYDIR 0 #endif -/* Events that inotify-add-watch waits for. This list has all the - events that any watcher could include, because we want to support - multiple watches on the same file even though inotify uses the same - descriptor for all watches to that file. This list omits - IN_ACCESS, IN_CLOSE_WRITE, IN_CLOSE_NOWRITE, and IN_OPEN because - they would prevent other processes from reading; see Bug#26973. - - FIXME: Explain why it is OK to omit these four bits here even - though a inotify-add-watch call might specify them. */ - -#define INOTIFY_DEFAULT_MASK \ - (IN_ATTRIB | IN_CREATE | IN_DELETE | IN_DELETE_SELF \ - | IN_IGNORED | IN_MODIFY | IN_MOVE_SELF | IN_MOVED_FROM \ - | IN_MOVED_TO | IN_EXCL_UNLINK) - /* File handle for inotify. */ static int inotifyfd = -1; @@ -436,8 +421,7 @@ IN_ONESHOT */) Lisp_Object encoded_file_name; int wd = -1; uint32_t imask = aspect_to_inotifymask (aspect); - uint32_t mask = (INOTIFY_DEFAULT_MASK - | (imask & (IN_DONT_FOLLOW | IN_ONLYDIR))); + uint32_t mask = imask | IN_MASK_ADD | IN_EXCL_UNLINK; CHECK_STRING (filename); -- 2.9.4 --------------F39056AE57A8528BC4C05647--