all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: riccardo.murri@gmail.com (Riccardo Murri)
To: bug-gnu-emacs@gnu.org
Subject: url-retrieve-synchronously randomly fails on https URLs (patch included)
Date: Sat, 27 Oct 2007 12:47:16 +0200 (CEST)	[thread overview]
Message-ID: <20071027104716.E9BA773545@tanja.localdomain> (raw)


To trigger the error just try a few times::

  (url-retrieve-synchronously "https://www.google.com/")


Error backtrace::

  Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
    url-http-wait-for-headers-change-function(1 199 198)
    url-http-generic-filter(#<process www.google.com> "EF344D7E1950942DBA877D79DDD8100A21A2592D03A210A4109\n    Key-Arg   : None\n    Start Time: 1193480981\n    Timeout   : 300 (sec)\n    Verify return code: 20 (unable to get local issuer certificate)\n---\n")
    accept-process-output(#<process www.google.com>)
    byte-code("=8c2\x18=8c3	!)=87" [inhibit-quit proc nil accept-process-output] 2)
    url-retrieve-synchronously("https://www.google.com/")
    (kill-buffer (url-retrieve-synchronously "https://www.google.com/"))
    eval((kill-buffer (url-retrieve-synchronously "https://www.google.com/")))
    eval-last-sexp-1(t)
    eval-last-sexp(t)
    eval-print-last-sexp()
    call-interactively(eval-print-last-sexp)


Sample contents of the URL retrieve buffer after a failed request::

  EF344D7E1950942DBA877D79DDD8100A21A2592D03A210A4109
      Key-Arg   : None
      Start Time: 1193480981
      Timeout   : 300 (sec)
      Verify return code: 20 (unable to get local issuer certificate)
  ---
  HTTP/1.1 302 Found

  Location: http://www.google.com

  Date: Sat, 27 Oct 2007 10:29:41 GMT

  Content-Type: text/html; charset=UTF-8

  Server: GFE/1.3

  Content-Length: 218

  

  <HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
  <TITLE>302 Moved</TITLE></HEAD><BODY>
  <H1>302 Moved</H1>
  The document has moved
  <A HREF="http://www.google.com">here</A>.

  </BODY></HTML>

  read:errno=0


I traced down the bug to `open-tls-stream', which returns immediately
after having seen the regexp `tls-success' in the buffer.  However,
both `openssl s_client' and `gnutls' print more information after that
line, thus `open-tls-stream' may occasionally return the buffer to the
caller when point is still amidst openssl/gnutls output.  

A solution is to have `open-tls-stream' wait a little more to accept
output; after applying the patch below I cannot trigger the error
anymore.


--- src/emacs22/lisp/net/tls.el	2007-08-05 21:06:12.000000000 +0200
+++ emacs/lisp/tls.el	2007-10-27 12:23:47.000000000 +0200
@@ -154,9 +154,14 @@
             (sit-for 1)))
 	(message "Opening TLS connection with `%s'...%s" cmd
 		 (if done "done" "failed"))
-	(if done
-	    (setq done process)
-	  (delete-process process))))
+        (if (not done)
+            (delete-process process)
+          ;; both `openssl s_client' and `gnutls' print some more info
+          ;; after the line matched by regexp `tls-success'; wait here
+          ;; a bit more, so we can be sure that point is at the end of
+          ;; it all, before handing the buffer back to caller
+          (accept-process-output process 1)
+          (setq done process))))
     (message "Opening TLS connection to `%s'...%s"
 	     host (if done "done" "failed"))
     (when use-temp-buffer


Riccardo




In GNU Emacs 22.1.1 (powerpc-unknown-linux-gnu, GTK+ Version 2.10.13)
 of 2007-08-22 on voltaire, modified by Debian
Windowing system distributor `The X.Org Foundation', version 11.0.70101000
configured using `configure  '--build=powerpc-linux-gnu' '--host=powerpc-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--localstatedir=/var/lib' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes' '--enable-locallisppath=/etc/emacs22:/etc/emacs:/usr/local/share/emacs/22.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/22.1/site-lisp:/usr/share/emacs/site-lisp:/usr/share/emacs/22.1/leim' '--with-x=yes' '--with-x-toolkit=gtk' '--with-toolkit-scroll-bars' 'build_alias=powerpc-linux-gnu' 'host_alias=powerpc-linux-gnu' 'CFLAGS=-DDEBIAN -g -O2''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: it_IT.UTF-8
  locale-coding-system: utf-8
  default-enable-multibyte-characters: t

Major mode: Text

Minor modes in effect:
  tooltip-mode: t
  tool-bar-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  unify-8859-on-encoding-mode: t
  utf-translate-cjk-mode: t
  auto-compression-mode: t
  line-number-mode: t

Recent input:
<down> <down> <right> <right> C-SPC C-e <escape> w 
C-x 4 b <return> C-y C-j <left> <backspace> C-x C-e 
C-x C-e C-x C-e C-x C-e C-x C-e C-x C-e C-x C-e C-x 
0 <help-echo> <help-echo> <help-echo> <help-echo> <help-echo> 
<help-echo> <menu-bar> <help-menu> <report-emacs-b
ug>

Recent messages:
t
Contacting host: www.google.com:443
Reading [text/html; charset=UTF-8]... 226 bytes of 218 bytes (104%)
Reading... done.
Reading [text/html]... 227 bytes of 218 bytes (104%)
www.google.it tried to set a cookie for domain .google.it - rejected.
t
Loading emacsbug...
Loading regexp-opt...done
Loading emacsbug...done




             reply	other threads:[~2007-10-27 10:47 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-27 10:47 Riccardo Murri [this message]
2007-10-27 23:41 ` url-retrieve-synchronously randomly fails on https URLs (patch included) Richard Stallman
2007-10-28 12:40   ` Riccardo Murri
2007-10-29  9:22     ` Richard Stallman
2007-10-29 20:48       ` Riccardo Murri
2007-10-30  5:24         ` Richard Stallman
2007-10-30 10:23           ` Riccardo Murri
2007-11-02 15:02         ` Richard Stallman
2007-11-02 22:18           ` Reiner Steib
2007-11-02 22:37             ` Miles Bader
2007-11-02 22:50               ` Lennart Borgman (gmail)
2007-11-03  5:48                 ` tomas
2007-11-03  9:35                   ` Andreas Schwab
2007-11-04  1:26           ` Glenn Morris
2007-11-05 10:26           ` Simon Josefsson
2007-11-05 15:01             ` Stefan Monnier
2007-11-05 15:04               ` Simon Josefsson
     [not found]                 ` <E1IpDzF-0003i4-EJ@fencepost.gnu.org>
2007-11-08 13:20                   ` Simon Josefsson
2007-11-06 11:22             ` Riccardo Murri

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=20071027104716.E9BA773545@tanja.localdomain \
    --to=riccardo.murri@gmail.com \
    --cc=bug-gnu-emacs@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.