From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: thomas@m3y3r.de Newsgroups: gmane.emacs.bugs Subject: bug#32658: gnutls + non-blocking url-retrieve Date: Sun, 07 Oct 2018 15:42:29 +0200 Message-ID: <864ldx6fga.fsf@DESKTOP-DQBDJ0U.i-did-not-set--mail-host-address--so-tickle-me> References: <861sa5zmpt.fsf@DESKTOP-DQBDJ0U.i-did-not-set--mail-host-address--so-tickle-me> <86tvm6smax.fsf@DESKTOP-DQBDJ0U.i-did-not-set--mail-host-address--so-tickle-me> <83efda431j.fsf@gnu.org> <86d0srp14s.fsf@DESKTOP-DQBDJ0U.i-did-not-set--mail-host-address--so-tickle-me> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1538919671 30604 195.159.176.226 (7 Oct 2018 13:41:11 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 7 Oct 2018 13:41:11 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1.50 (windows-nt) Cc: 32658@debbugs.gnu.org To: thomas@m3y3r.de Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Oct 07 15:41:07 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g99It-0007m5-B0 for geb-bug-gnu-emacs@m.gmane.org; Sun, 07 Oct 2018 15:41:03 +0200 Original-Received: from localhost ([::1]:42468 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g99Kz-0001eH-D1 for geb-bug-gnu-emacs@m.gmane.org; Sun, 07 Oct 2018 09:43:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44446) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g99Ks-0001e8-0z for bug-gnu-emacs@gnu.org; Sun, 07 Oct 2018 09:43:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g99Ko-0007DM-Nh for bug-gnu-emacs@gnu.org; Sun, 07 Oct 2018 09:43:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:34887) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g99Ko-0007Cw-Jk for bug-gnu-emacs@gnu.org; Sun, 07 Oct 2018 09:43:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1g99Ko-0003eb-Am for bug-gnu-emacs@gnu.org; Sun, 07 Oct 2018 09:43:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: thomas@m3y3r.de Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 07 Oct 2018 13:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 32658 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 32658-submit@debbugs.gnu.org id=B32658.153891976214019 (code B ref 32658); Sun, 07 Oct 2018 13:43:02 +0000 Original-Received: (at 32658) by debbugs.gnu.org; 7 Oct 2018 13:42:42 +0000 Original-Received: from localhost ([127.0.0.1]:39145 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g99KT-0003e2-Ap for submit@debbugs.gnu.org; Sun, 07 Oct 2018 09:42:42 -0400 Original-Received: from www17.your-server.de ([213.133.104.17]:52762) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g99KP-0003dm-Sz for 32658@debbugs.gnu.org; Sun, 07 Oct 2018 09:42:39 -0400 Original-Received: from [78.46.172.2] (helo=sslproxy05.your-server.de) by www17.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1g99KI-0004Nl-Pi; Sun, 07 Oct 2018 15:42:30 +0200 Original-Received: from [95.222.30.186] (helo=DESKTOP-DQBDJ0U) by sslproxy05.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1g99KI-0008ff-KV; Sun, 07 Oct 2018 15:42:30 +0200 In-Reply-To: <86d0srp14s.fsf@DESKTOP-DQBDJ0U.i-did-not-set--mail-host-address--so-tickle-me> (thomas's message of "Wed, 03 Oct 2018 16:15:31 +0200") X-Authenticated-Sender: thomas@m3y3r.de X-Virus-Scanned: Clear (ClamAV 0.100.1/25014/Sun Oct 7 06:49:59 2018) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:150978 Archived-At: thomas@m3y3r.de writes: > Eli Zaretskii writes: > >>> From: thomas@m3y3r.de >>> Date: Sun, 30 Sep 2018 23:33:10 +0200 >>> >>> 1.) I needed to revert to gnutls 3.5.19, the mingw64 build from the >>> gitlab ci build seems to have a working gnutls-cli tools on windows 10. >>> the gitlab builds for 3.6.3 and 3.6.4 seems to have another bug >>> (error code -53) in the gnutls-cli command. >>> >>> so only gnutls 3.5.19 have a working gnutls-cli. i installed this version in emacs 26.1 >>> >>> 2.) testing gnutls stream >>> using open-gnutls-stream directly gives me a correct tls connection but >>> eww still fails to load the site. >>> >>> when I change url-open-stream in url/url-gw.el to: >>> (open-network-stream >>> name buffer host service >>> :type gw-method >>> ;; Use non-blocking socket if we can. >>> :nowait nil)) >>> >>> I finally can open lwn.net in eww. >>> >>> so something seems to be wrong possible with blocking/non-blocking >>> network access. >>> >>> any ideas? >> >> Thanks for the info. > okay, some more infos. I was able to bootstrap the emacs compile with mingw64. while I was trying to debug this problem with fprintf, eww suddenly started to work!! It started to work after I did insert an fprintf after the gnutls_try_handshake call in process.c !! what is going on here? diff --git a/src/gnutls.c b/src/gnutls.c index 9e105b948f..374dfeb6e5 100644 --- a/src/gnutls.c +++ b/src/gnutls.c @@ -583,6 +583,7 @@ gnutls_try_handshake (struct Lisp_Process *proc) { gnutls_session_t state = proc->gnutls_state; int ret; + bool non_fatal; bool non_blocking = proc->is_non_blocking_client; if (proc->gnutls_complete_negotiation_p) @@ -594,11 +595,11 @@ gnutls_try_handshake (struct Lisp_Process *proc) do { ret = gnutls_handshake (state); - emacs_gnutls_handle_error (state, ret); + non_fatal = emacs_gnutls_handle_error (state, ret); maybe_quit (); } while (ret < 0 - && gnutls_error_is_fatal (ret) == 0 + && non_fatal && ! non_blocking); proc->gnutls_initstage = GNUTLS_STAGE_HANDSHAKE_TRIED; @@ -779,7 +780,7 @@ emacs_gnutls_handle_error (gnutls_session_t session, int err) /* TODO: use a Lisp_Object generated by gnutls_make_error? */ if (err >= 0) - return 1; + return true; check_memory_full (err); diff --git a/src/process.c b/src/process.c index b0a327229c..5bdb74868c 100644 --- a/src/process.c +++ b/src/process.c @@ -899,6 +899,10 @@ static void remove_process (register Lisp_Object proc) { register Lisp_Object pair; + struct Lisp_Process *lp = XPROCESS(proc); + + fprintf (stderr, "DEBUG: remove process called for proc %s ", SDATA(lp->name) /*, status_message(&lp->status) */); + fprintf (stderr, "gnutls_initstage: %u\n", lp->gnutls_initstage); pair = Frassq (proc, Vprocess_alist); Vprocess_alist = Fdelq (pair, Vprocess_alist); @@ -3283,6 +3287,8 @@ finish_after_tls_connection (Lisp_Object proc) Lisp_Object contact = p->childp; Lisp_Object result = Qt; + add_to_log("DEBUG: finish_after_tls_connection"); + if (!NILP (Ffboundp (Qnsm_verify_connection))) result = call3 (Qnsm_verify_connection, proc, @@ -5097,9 +5103,12 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, if (p->gnutls_initstage == GNUTLS_STAGE_HANDSHAKE_TRIED && p->is_non_blocking_client) { - gnutls_try_handshake (p); + fprintf (stderr, "DEBUG: trying_gnutls_handshake: %s, %lld, %d, %d, %d\n", SDATA(p->name), time_limit, nsecs, read_kbd, do_display); + int rcgt = gnutls_try_handshake (p); p->gnutls_handshakes_tried++; + fprintf (stderr, "DEBUG: after gnutls_handshake: %d, %d, %u\n", rcgt, p->gnutls_handshakes_tried, p->gnutls_initstage); + if (p->gnutls_initstage == GNUTLS_STAGE_READY) { gnutls_verify_boot (aproc, Qnil); Here the output of stderr: DEBUG: trying_gnutls_handshake: lwn.net<1>, 1, 843955000, -1, 1 DEBUG: after gnutls_handshake: -28, 1, 8 DEBUG: trying_gnutls_handshake: lwn.net<1>, 1, 650501000, -1, 1 DEBUG: after gnutls_handshake: -28, 2, 8 DEBUG: trying_gnutls_handshake: lwn.net<1>, 1, 650501000, -1, 1 DEBUG: after gnutls_handshake: -28, 3, 8 DEBUG: trying_gnutls_handshake: lwn.net<1>, 1, 650501000, -1, 1 DEBUG: after gnutls_handshake: -28, 4, 8 DEBUG: trying_gnutls_handshake: lwn.net<1>, 1, 650501000, -1, 1 DEBUG: after gnutls_handshake: -28, 5, 8 DEBUG: trying_gnutls_handshake: lwn.net<1>, 1, 650501000, -1, 1 DEBUG: after gnutls_handshake: -28, 6, 8 DEBUG: trying_gnutls_handshake: lwn.net<1>, 1, 650501000, -1, 1 DEBUG: after gnutls_handshake: -28, 7, 8 DEBUG: trying_gnutls_handshake: lwn.net<1>, 1, 650501000, -1, 1 DEBUG: after gnutls_handshake: 0, 8, 9 DEBUG: remove process called for proc lwn.net gnutls_initstage: 0 DEBUG: remove process called for proc lwn.net<1> gnutls_initstage: 3 DEBUG: trying_gnutls_handshake: lwn.net, 30, 0, -1, 1 DEBUG: after gnutls_handshake: -28, 1, 8 DEBUG: trying_gnutls_handshake: lwn.net, 30, 0, -1, 1 DEBUG: after gnutls_handshake: -28, 2, 8 DEBUG: trying_gnutls_handshake: lwn.net, 30, 0, -1, 1 DEBUG: after gnutls_handshake: -28, 3, 8 DEBUG: trying_gnutls_handshake: lwn.net, 30, 0, -1, 1 DEBUG: after gnutls_handshake: -28, 4, 8 DEBUG: trying_gnutls_handshake: lwn.net, 30, 0, -1, 1 DEBUG: after gnutls_handshake: -28, 5, 8 DEBUG: trying_gnutls_handshake: lwn.net, 30, 0, -1, 1 DEBUG: after gnutls_handshake: -28, 6, 8 DEBUG: trying_gnutls_handshake: lwn.net, 30, 0, -1, 1 DEBUG: after gnutls_handshake: -28, 7, 8 DEBUG: trying_gnutls_handshake: lwn.net, 30, 0, -1, 1 DEBUG: after gnutls_handshake: -28, 8, 8 DEBUG: trying_gnutls_handshake: lwn.net, 30, 0, -1, 1 DEBUG: after gnutls_handshake: 0, 9, 9 DEBUG: remove process called for proc lwn.net gnutls_initstage: 3 maybe this problem seems to be an timing and/or cpu issue? my laptop uses an relativley new intel core i7-7500u cpu.