unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: michael.albinus@gmx.de
Cc: 22534@debbugs.gnu.org, fabrice.popineau@gmail.com
Subject: bug#22534: File notify broken on Windows
Date: Sat, 06 Feb 2016 18:53:04 +0200	[thread overview]
Message-ID: <83wpqhsrv3.fsf@gnu.org> (raw)
In-Reply-To: <83si17t02p.fsf@gnu.org> (message from Eli Zaretskii on Fri, 05 Feb 2016 21:43:26 +0200)

> Date: Fri, 05 Feb 2016 21:43:26 +0200
> From: Eli Zaretskii <eliz@gnu.org>
> Cc: 22534@debbugs.gnu.org, fabrice.popineau@gmail.com
> 
> > From: Michael Albinus <michael.albinus@gmx.de>
> > Cc: Eli Zaretskii <eliz@gnu.org>,  22534@debbugs.gnu.org
> > Date: Fri, 05 Feb 2016 18:18:59 +0100
> > 
> > > I have tried with different values of file-notify--test-timeout but it
> > > doesn't seem to make any difference. I also boosted the size of the
> > > file_notifications[] array (* 16) without any difference. I have
> > > tested with sit-for between each rename operation and it does not work
> > > either above 260 files
> > 
> > Is it worth to continue to look for the problem in w32notify? I would simply
> > set the loop limit there to 250, that's it.
> 
> It would be a waste of your time to look into that.  Go ahead and
> lower the number; I will look into the problem when I have time and
> see what come up with.  We can then pick up where we left off.

I've looked into this.  The simple patch below fixes the test for me.

The problem was that all the 1000 renames were run in a single long
series.  On MS-Windows this generates 2000 events, because the target
file exists and needs to be deleted first.  However, w32notify has a
static limit of about 1000 events it can collect without losing some
(that's on a 32-bit system, probably less on a 64-bit OS).  The last
part of the riddle is that in batch mode file notifications are not
read on MS-Windows unless someone calls read-event or a similar
function that calls 'pselect' to check for input.  If they are not
read, they keep accumulating, and are then reported all together.

I also suspect that the Windows API use by w32notify has its own limit
of events it can accumulate, and beyond that limit simply drops the
older events on the floor.

The solution is to call read-event while renaming the files.  Then I
could go back to 1000 renames without failures.

Michael, is there a reason not to issue those additional calls to
read-event on other platforms?  If necessary, those calls could be
made conditional on MS-Windows.

Here's the proposed patch.  Fabrice, please see if this works for you
(the full test runs for about 7 minutes, so be patient).  Btw, we
could make the test run faster by lowering the 0.1 argument to the 2
read-event calls while we create the 2000 files at the beginning of
the test, I see no need for waiting that long for a single file
creation.

diff --git a/test/automated/file-notify-tests.el b/test/automated/file-notify-tests.el
index 629d85b..5fc4ff8 100644
--- a/test/automated/file-notify-tests.el
+++ b/test/automated/file-notify-tests.el
@@ -66,7 +66,7 @@ file-notify--test-timeout
   "Timeout to wait for arriving events, in seconds."
   (cond
    ((file-remote-p temporary-file-directory) 6)
-   ((string-equal (file-notify--test-library) "w32notify") 20)
+   ((string-equal (file-notify--test-library) "w32notify") 10)
    ((eq system-type 'cygwin) 10)
    (t 3)))
 
@@ -797,10 +797,7 @@ file-notify--test-with-events
 	  file-notify--test-tmpfile
 	  '(change) 'file-notify--test-event-handler)))
   (unwind-protect
-      ;; In case of w32notify, the upper limit of events to handle
-      ;; seems to be 260.  Reason unknown.
-      (let ((n (if (string-equal (file-notify--test-library) "w32notify")
-                   250 1000))
+      (let ((n 1000)
             source-file-list target-file-list
             (default-directory file-notify--test-tmpfile))
         (dotimes (i n)
@@ -832,10 +829,11 @@ file-notify--test-with-events
           (let ((source-file-list source-file-list)
                 (target-file-list target-file-list))
             (while (and source-file-list target-file-list)
-              (rename-file (pop source-file-list) (pop target-file-list) t))))
+              (rename-file (pop source-file-list) (pop target-file-list) t)
+              (read-event nil nil 0.02))))
         (file-notify--test-with-events (make-list n 'deleted)
           (dolist (file target-file-list)
-            (delete-file file))))
+            (prog1 (delete-file file) (read-event nil nil 0.02)))))
     (file-notify--test-cleanup)))
 
 (file-notify--deftest-remote file-notify-test06-many-events





  parent reply	other threads:[~2016-02-06 16:53 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-02  6:23 bug#22534: File notify broken on Windows Fabrice Popineau
2016-02-02 16:15 ` Eli Zaretskii
2016-02-02 23:36   ` Fabrice Popineau
2016-02-03  8:07     ` Michael Albinus
2016-02-03 12:15       ` Fabrice Popineau
2016-02-04  9:49         ` Fabrice Popineau
2016-02-04 18:47           ` Eli Zaretskii
2016-02-05  5:59             ` Fabrice Popineau
2016-02-05 10:10               ` Eli Zaretskii
2016-02-05 15:34                 ` Fabrice Popineau
2016-02-05 17:18                   ` Michael Albinus
2016-02-05 19:43                     ` Eli Zaretskii
2016-02-05 21:58                       ` Michael Albinus
2016-02-06 16:53                       ` Eli Zaretskii [this message]
2016-02-06 19:24                         ` Michael Albinus
2016-02-06 19:55                           ` Eli Zaretskii
2016-02-07 13:37                             ` Fabrice Popineau
2016-02-07 17:46                               ` Eli Zaretskii
2016-02-07 18:37                                 ` Michael Albinus
2016-02-07 19:34                                 ` Fabrice Popineau
2016-02-08 10:27                                   ` Michael Albinus
2016-02-08 10:43                                     ` Fabrice Popineau
2016-02-08 18:09                                       ` Eli Zaretskii
2016-02-08 19:14                                         ` Michael Albinus
2016-02-08 19:36                                           ` Eli Zaretskii
2016-02-08 20:00                                             ` Michael Albinus
2016-02-08 20:18                                               ` Eli Zaretskii
2016-02-08 20:51                                                 ` Michael Albinus
2016-02-08 21:03                                                   ` Eli Zaretskii
2016-02-08 21:13                                                     ` Michael Albinus
2016-02-09  3:35                                                       ` Eli Zaretskii
2016-02-09  8:13                                                         ` Michael Albinus
2016-02-09 10:08                                                           ` Michael Albinus
2016-02-09 17:09                                                             ` Eli Zaretskii
2016-02-09 18:47                                                               ` Michael Albinus
2016-02-10 11:25                                                                 ` Michael Albinus
2016-02-08 19:15                                         ` Fabrice Popineau
2016-02-10 19:15                                           ` Eli Zaretskii
2016-02-11 15:19                                             ` Fabrice Popineau
2016-02-12  8:38                                               ` Eli Zaretskii
2016-02-15 15:31                                             ` Michael Albinus
2016-02-15 15:59                                               ` Eli Zaretskii
2016-02-15 17:52                                                 ` Michael Albinus
2016-02-15 19:46                                                   ` Fabrice Popineau
2016-02-08 10:21                               ` Michael Albinus
2016-02-08 10:40                                 ` Fabrice Popineau
2016-02-08 14:33                                   ` Fabrice Popineau
2016-02-05 19:31                   ` Eli Zaretskii
2016-02-05 17:23                 ` Michael Albinus
     [not found] ` <CAFgFV9P2D6-dcuHnZ2VQ6F2sW85Aj3AZWL85RJxai-LyuE87xw@mail.gmail.com>
     [not found]   ` <CAFgFV9MghLviOcmwmDmasZNmkDjZfoBSuwFOoSHXQNtxxkg9mA@mail.gmail.com>
     [not found]     ` <83egcbun0o.fsf@gnu.org>
     [not found]       ` <CAFgFV9Og72xHW5O9JE8og=7NrTgeMvx01bg_HBOYzduH1vjLfQ@mail.gmail.com>
     [not found]         ` <8360xnukzx.fsf@gnu.org>
     [not found]           ` <CAFgFV9N-+bZf-bBXFaDNsv3dvFQjJbpggPMJrcZ30M-HSaZDwg@mail.gmail.com>
     [not found]             ` <83a8mvprbg.fsf@gnu.org>
     [not found]               ` <CAFgFV9Patgn1GJrDkSeMKsS4cewdQRp4F8VYoftybTQ5TmfPAg@mail.gmail.com>
     [not found]                 ` <83oabbnxvs.fsf@gnu.org>
     [not found]                   ` <CAFgFV9N55HuPkF+mVx6Eh9szUUxhu+BkF-2KJ7nx46-3wsph5Q@mail.gmail.com>
     [not found]                     ` <83io1glmkg.fsf@gnu.org>
     [not found]                       ` <CAFgFV9PxijF1Q3WPo1Ebfqe4cJQVYyiu4bOm41QV4L_OvYZ35w@mail.gmail.com>
     [not found]                         ` <87y4abtwhq.fsf@gmx.de>
     [not found]                           ` <8337sjjsql.fsf@gnu.org>
     [not found]                             ` <CAFgFV9MkwdPHxf_6VqYZdBt8vXwbBUxcOivkCyZWYTvi0H24XQ@mail.gmail.com>
     [not found]                               ` <87ziuc3gay.fsf@gmx.de>
     [not found]                                 ` <83twkkwxdi.fsf@gnu.org>
     [not found]                                   ` <CAFgFV9MdwHK8OG69Dpw6wPj6FK9Fi5c3vQ_jFZaz1BfgGLBLbw@mail.gmail.com>
     [not found]                                     ` <83mvqcwa2v.fsf@gnu.org>
     [not found]                                       ` <CAFgFV9NTSw1LKn_CzrKxNmZvRMbqrctSEer_8oaniH+Lti=n6g@mail.gmail.com>
2016-03-08  7:44                                         ` Michael Albinus
     [not found]                                         ` <83r3fil7z3.fsf@gnu.org>
     [not found]                                           ` <CAFgFV9Pkmz0E7h4mfCLCcxmt29dbDNfAOOp=mbPKnCpPt1B3LQ@mail.gmail.com>
     [not found]                                             ` <83bn6ljbku.fsf@gnu.org>
     [not found]                                               ` <CAFgFV9PnLRZ=2-C4S9jSMpmDUxijCUQQnu-YnAv2-ifm+6kZBA@mail.gmail.com>
     [not found]                                                 ` <83fuvm8wjx.fsf@gnu.org>
2016-03-19 14:51                                                   ` Michael Albinus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83wpqhsrv3.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=22534@debbugs.gnu.org \
    --cc=fabrice.popineau@gmail.com \
    --cc=michael.albinus@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).