Subject: bug#20159: 24.4; url-retrieve invokes same callback twice with kill-buffer

From: Lars Ingebrigtsen <[email-masked]>
Date: Tue, 01 Mar 2016 15:04:37 +1100

Lars Ingebrigtsen <[email-masked]> writes:

> Eli fixed something related to this, but the bug still remains.  I used
> this version:
>
> ;;; -*- lexical-binding: t; -*-
> (let ((calls 0))
>   (url-retrieve "http://localhost:1/"
>                 (lambda (status)
> 		  (message "%s '%s'" calls status)
>                   (assert (= 1 (cl-incf calls)))
> 		  (kill-buffer))))
>
> These are the messages:
>
> Contacting host: localhost:1
> #<buffer  *http localhost:1*-537967>
> 0 ’(:error (error connection-failed failed with code 111
>  :host localhost :service 1))’
> 1 ’(:error (error connection-failed deleted
>  :host localhost :service 1) :error (error connection-failed failed with code 111
>  :host localhost :service 1))’
>
> The second message is...  pretty weird...
>
> Anybody have a guess why this happens?

I've done some further debugging, and what's happening is (simply, ahem)
that when we get a "connection failed" message from the sentinel, and
then kill the buffer, we also kill the process, and then the sentinel is
called again, and then it calls our callback again.

So the weird thing is that the process isn't already dead, kinda...  Or
something...

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no