unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: Dmitry <dgutov@yandex.ru>
Cc: 18116@debbugs.gnu.org
Subject: bug#18116: 24.3.92; url-http calls CALLBACK recursively with malformed CBARGS if the former calls `delete-process'
Date: Tue, 09 Sep 2014 22:24:46 -0400	[thread overview]
Message-ID: <jwvsik0fddg.fsf-monnier+emacsbugs@gnu.org> (raw)
In-Reply-To: <86ppgr4hqe.fsf@yandex.ru> (Dmitry's message of "Sun, 27 Jul 2014 06:12:57 +0300")

> (require 'url-http)
> (defvar uht-counter 0)
> (defun uht-callback (status)
>   (declare (special url-http-process))
>   (message "%s %s" uht-counter status)
>   (delete-process url-http-process))
> (defun uht-test ()
>   (setq uht-counter (1+ uht-counter))
>   ;; The port must not be open.
>   (url-http (url-generic-parse-url "http://localhost:3333") #'uht-callback (list 'foo)))

[ Thanks a lot Óscar for bisecting this one.  ]

Dmitry, could you explain a bit more of the context?

The problem is that calling `delete-process' may run the sentinel (and
since this is code run from the sentinel, it may end up calling the
sentinel recursively).

So if you don't want the sentinel to be called recursively, you'll want
to (set-process-sentinel url-http-process nil) before calling
delete-process (or refrain from calling delete-process).

> If the callback expects STATUS to contain some specific data structure,
> that can cause breakage, see https://github.com/marijnh/tern/issues/350
> for an example.

The format looks normal: the STATUS is expected to be a plist holding
the "history" of the connection.  It can contain various ":error FOO"
and ":redirect BAR" entries.

I think the problem comes from a doc error, where url-http points to
url-retrieve for the doc of CBARGS, whereas it uses the format of
url-retrieve-internal instead.


        Stefan





  parent reply	other threads:[~2014-09-10  2:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-27  3:12 bug#18116: 24.3.92; url-http calls CALLBACK recursively with malformed CBARGS if the former calls `delete-process' Dmitry
2014-08-13 17:06 ` Glenn Morris
2014-08-18 19:34 ` Óscar Fuentes
2014-09-10  2:24 ` Stefan Monnier [this message]
2014-09-11  1:52   ` Dmitry Gutov
2014-09-12 17:22     ` Stefan Monnier
2014-09-19  2:00       ` Dmitry Gutov

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=jwvsik0fddg.fsf-monnier+emacsbugs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=18116@debbugs.gnu.org \
    --cc=dgutov@yandex.ru \
    /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).