From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alain Schneble Newsgroups: gmane.emacs.bugs Subject: bug#22789: 25.1.50; In last master build https connections stop working Date: Fri, 4 Mar 2016 23:33:46 +0100 Message-ID: <8660x1lvp1.fsf@realize.ch> References: <864mcyo14y.fsf@Lenovo-PC.i-did-not-set--mail-host-address--so-tickle-me> <871t81wtyt.fsf@gnus.org> <87r3g1veqc.fsf@gnus.org> <86si0euizj.fsf@realize.ch> <871t7xhj7t.fsf@gnus.org> <86oab1vjm9.fsf@realize.ch> <86d1rhpvcq.fsf@realize.ch> <834mctbitq.fsf@gnu.org> <868u25p3m2.fsf@realize.ch> <83io18ahya.fsf@gnu.org> <86y4a3on6f.fsf@realize.ch> <87oaazg7fv.fsf@gnus.org> <86twkro0vr.fsf@realize.ch> <83d1rf8ifj.fsf@gnu.org> <86povfnm9r.fsf@realize.ch> <8337sa9865.fsf@gnu.org> <86bn6ynrbw.fsf@realize.ch> <83vb566v5b.fsf@gnu.org> <83d1razkmq.fsf@gnu.org> <86egbqkwsb.fsf@realize.ch> <86a8mekjrb.fsf@realize.ch> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1457130920 28934 80.91.229.3 (4 Mar 2016 22:35:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 4 Mar 2016 22:35:20 +0000 (UTC) Cc: larsi@gnus.org, j_l_domenech@yahoo.com, 22789@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Mar 04 23:35:11 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1abyJR-0002qh-TH for geb-bug-gnu-emacs@m.gmane.org; Fri, 04 Mar 2016 23:35:10 +0100 Original-Received: from localhost ([::1]:43828 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1abyJR-0001jl-9X for geb-bug-gnu-emacs@m.gmane.org; Fri, 04 Mar 2016 17:35:09 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38780) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1abyJN-0001jU-FA for bug-gnu-emacs@gnu.org; Fri, 04 Mar 2016 17:35:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1abyJK-0001lc-5s for bug-gnu-emacs@gnu.org; Fri, 04 Mar 2016 17:35:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:37034) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1abyJK-0001l6-2r for bug-gnu-emacs@gnu.org; Fri, 04 Mar 2016 17:35:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84) (envelope-from ) id 1abyJJ-0004LH-LW for bug-gnu-emacs@gnu.org; Fri, 04 Mar 2016 17:35:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alain Schneble Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 04 Mar 2016 22:35:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22789 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 22789-submit@debbugs.gnu.org id=B22789.145713088916670 (code B ref 22789); Fri, 04 Mar 2016 22:35:01 +0000 Original-Received: (at 22789) by debbugs.gnu.org; 4 Mar 2016 22:34:49 +0000 Original-Received: from localhost ([127.0.0.1]:34161 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1abyJ6-0004Kn-VC for submit@debbugs.gnu.org; Fri, 04 Mar 2016 17:34:49 -0500 Original-Received: from clientmail.realize.ch ([46.140.89.53]:2987) by debbugs.gnu.org with smtp (Exim 4.84) (envelope-from ) id 1abyJ4-0004KX-Nm for 22789@debbugs.gnu.org; Fri, 04 Mar 2016 17:34:47 -0500 Original-Received: from rintintin.hq.realize.ch.lan.rit ([192.168.0.105]) by clientmail.realize.ch ; Fri, 4 Mar 2016 23:34:23 +0100 Original-Received: from MYNGB (192.168.250.224) by rintintin.hq.realize.ch.lan.rit (192.168.0.105) with Microsoft SMTP Server (TLS) id 15.0.516.32; Fri, 4 Mar 2016 23:34:01 +0100 In-Reply-To: <86a8mekjrb.fsf@realize.ch> (Alain Schneble's message of "Fri, 4 Mar 2016 22:36:56 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (windows-nt) X-ClientProxiedBy: rintintin.hq.realize.ch.lan.rit (192.168.0.105) To rintintin.hq.realize.ch.lan.rit (192.168.0.105) 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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:114433 Archived-At: --=-=-= Content-Type: text/plain Alain Schneble writes: > Alain Schneble writes: > > And here is the intermediate-and-not-cleaned-up patch: Sorry, the former patch did break the new retry_for_async flag. Here is a corrected one (but still experimental...): --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename="0001-Wait-for-GnuTLS-handshake-until-socket-is-connected.patch" Content-Description: Patch >From eedbcea0224febf579bedb44a9bb2b280abcdc4a Mon Sep 17 00:00:00 2001 From: Alain Schneble Date: Fri, 4 Mar 2016 23:17:07 +0100 Subject: [PATCH] Wait for GnuTLS handshake until socket is connected * src/gnutls.c (emacs_gnutls_handshake, gnutls_try_handshake): Skip GnuTLS handshake when gnutls_boot is called on async socket (aka non blocking client). * src/process.c (connect_network_socket, wait_reading_process_output): Proceed with GnuTLS handshake only after async socket has been connected. --- src/gnutls.c | 9 ++++++--- src/process.c | 13 +++++++++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/gnutls.c b/src/gnutls.c index 988c010..4962ecc 100644 --- a/src/gnutls.c +++ b/src/gnutls.c @@ -403,9 +403,6 @@ gnutls_try_handshake (struct Lisp_Process *proc) gnutls_session_t state = proc->gnutls_state; int ret; - if (proc->is_non_blocking_client) - proc->gnutls_p = true; - do { ret = gnutls_handshake (state); @@ -474,6 +471,12 @@ emacs_gnutls_handshake (struct Lisp_Process *proc) proc->gnutls_initstage = GNUTLS_STAGE_TRANSPORT_POINTERS_SET; } + if (proc->is_non_blocking_client) + { + proc->gnutls_p = true; + return GNUTLS_E_AGAIN; + } + return gnutls_try_handshake (proc); } diff --git a/src/process.c b/src/process.c index 4359f68..d73586c 100644 --- a/src/process.c +++ b/src/process.c @@ -3415,7 +3415,8 @@ connect_network_socket (Lisp_Object proc, Lisp_Object ip_addresses) if (p->gnutls_initstage == GNUTLS_STAGE_READY) /* Run sentinels, etc. */ finish_after_tls_connection (proc); - else if (p->gnutls_initstage != GNUTLS_STAGE_HANDSHAKE_TRIED) + else if ((! p->is_non_blocking_client && p->gnutls_initstage != GNUTLS_STAGE_HANDSHAKE_TRIED) || + (p->is_non_blocking_client && p->gnutls_initstage != GNUTLS_STAGE_TRANSPORT_POINTERS_SET)) { deactivate_process (proc); if (NILP (boot)) @@ -4950,11 +4951,15 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, #endif #ifdef HAVE_GNUTLS /* Continue TLS negotiation. */ - if (p->gnutls_initstage == GNUTLS_STAGE_HANDSHAKE_TRIED + if ((p->gnutls_initstage == GNUTLS_STAGE_TRANSPORT_POINTERS_SET || + p->gnutls_initstage == GNUTLS_STAGE_HANDSHAKE_TRIED) && p->is_non_blocking_client) { - gnutls_try_handshake (p); - p->gnutls_handshakes_tried++; + if (! FD_ISSET (p->outfd, &connect_wait_mask)) + { + gnutls_try_handshake (p); + p->gnutls_handshakes_tried++; + } if (p->gnutls_initstage == GNUTLS_STAGE_READY) { -- 2.6.2.windows.1 --=-=-=--