unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#20159: 24.4; url-retrieve invokes same callback twice with kill-buffer
@ 2015-03-21 20:46 Christopher Wellons
  2015-03-21 21:00 ` Eli Zaretskii
  2015-12-25 18:30 ` Lars Ingebrigtsen
  0 siblings, 2 replies; 14+ messages in thread
From: Christopher Wellons @ 2015-03-21 20:46 UTC (permalink / raw)
  To: 20159


Emacs 24.4.1 on x86_64 Linux, the callback passed to `url-retrieve' is
invoked twice if `kill-buffer' is called within the callback when the
status reports a connection failure. In the example below, it's assumed
this URL will reject the connection, which will cause `url-retrieve' to
asynchronously invoke the callback with an error status ("failed with
code 111\n"). The second invocation of the callback is synchronous with
the first invocation, because it's called recursively from within the
`kill-buffer' call. The error message the second time is "deleted\n".

    ;;; -*- lexical-binding: t; -*-
    (let ((calls 0))
      (url-retrieve "http://localhost:1/"
                    (lambda (_)
                      (assert (= 1 (cl-incf calls)))
                      (kill-buffer))))

When I eval the above expression, the assertion fails asynchronously.

    error in process sentinel: Assertion failed: (= 1 (cl-incf calls))

I expect the callback given to `url-retrieve' to never be invoked more
than once each time it's passed to `url-retrieve'. Ideally I expect it
to be called exactly once for each call to `url-retrieve', always
delivering errors asynchronously.

I also tested this on a Windows build of Emacs. The callback is invoked
zero times because the connection error is delivered synchronously at
the call to `url-retrieve' (which I now realize explains why connection
queuing doesn't work right on Windows). So even if the double-invoke
problem is fixed for Linux, the behavior still differs across platforms.





^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2016-03-01  4:08 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-21 20:46 bug#20159: 24.4; url-retrieve invokes same callback twice with kill-buffer Christopher Wellons
2015-03-21 21:00 ` Eli Zaretskii
2015-03-21 21:48   ` Christopher Wellons
2015-03-22 17:31     ` Eli Zaretskii
2015-03-27  9:52       ` Eli Zaretskii
2015-03-27 16:59         ` Andy Moreton
2015-03-27 19:22           ` Eli Zaretskii
2015-03-27 19:40             ` Eli Zaretskii
2015-03-28  7:39               ` Eli Zaretskii
2015-03-28 10:56                 ` Andy Moreton
2015-03-28 11:28                   ` Eli Zaretskii
2015-12-25 18:30 ` Lars Ingebrigtsen
2016-03-01  4:04   ` Lars Ingebrigtsen
2016-03-01  4:08   ` Lars Ingebrigtsen

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).