all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Christopher Wellons <wellons@nullprogram.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 20159@debbugs.gnu.org
Subject: bug#20159: 24.4; url-retrieve invokes same callback twice with kill-buffer
Date: Sat, 21 Mar 2015 17:48:05 -0400	[thread overview]
Message-ID: <87egoi3tuy.fsf@wellocc1-ld2.jhuapl.edu> (raw)
In-Reply-To: <83y4mqrrp8.fsf@gnu.org>


>> 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.
>
> I don't understand what you mean by "error is delivered synchronously
> at the call", and by "connection queuing doesn't work right".  Please
> consider elaborating on those 2 points.

On Windows, url-retrieve doesn't return until the connection is either
established or fails, making the call mostly synchronous. If the remote
server takes 20 seconds to SYNACK, Emacs will lock up for 20 seconds
(and C-g doesn't work either!). For example, currently the server at
example.com doesn't seem to respond to anything, so try evaluating the
following on Windows. For me, Emacs freezes for 21 seconds, until timing
out, and the callback is never invoked.

    (url-retrieve "http://example.com:1/" (lambda (_)))

On Linux it returns immediately and about a minute later the callback is
invoked with an error status, timing out. I could call this 100 times in
a loop without locking up Emacs. On Windows 7 on my computer, this locks
up Emacs for half an hour, though hitting C-g will stop it within 21
seconds (between loop iterations):

    ;; Try it if you dare!
    (dotimes (_ 100)
      (ignore-errors
        (url-retrieve "http://example.com:1/" (lambda (_)))))

Since it's synchronous on Windows, the error can be reported directly to
the caller, which is what it does. The downside is awful performance and
inconsistent error reporting (sometimes synchronously to the caller,
sometimes asynchronously using the callback).

I maintain the Elfeed RSS/Atom reader. I've noticed over the past 1.5
years that its performance on Windows is very poor compared to Linux.
It's bad enough that I've disabled parallel fetching of feeds on
Windows. I see now that it's probably because url-retrieve isn't fully
synchronous there. If I call url-retrieve four times in a row to fire
off four connections, the TCP connections themselves will be performed
serially between calls and not in parallel, as it is on Linux, so
there's no point to doing so. They don't queue properly.

I hope that explains it well enough!





  reply	other threads:[~2015-03-21 21:48 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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

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

  git send-email \
    --in-reply-to=87egoi3tuy.fsf@wellocc1-ld2.jhuapl.edu \
    --to=wellons@nullprogram.com \
    --cc=20159@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.