From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Robert Pluim Newsgroups: gmane.emacs.devel Subject: Re: [RFC] automatically retrying network connections Date: Sun, 22 Jul 2018 16:08:26 +0200 Message-ID: <871sbv7485.fsf@gmail.com> References: <87sh4dfz8r.fsf@gmail.com> <87fu0bft72.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1532268402 30376 195.159.176.226 (22 Jul 2018 14:06:42 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 22 Jul 2018 14:06:42 +0000 (UTC) Cc: emacs-devel@gnu.org To: Lars Ingebrigtsen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jul 22 16:06:38 2018 Return-path: Envelope-to: ged-emacs-devel@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 1fhF0N-0007nb-Bw for ged-emacs-devel@m.gmane.org; Sun, 22 Jul 2018 16:06:35 +0200 Original-Received: from localhost ([::1]:56126 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhF2U-0004Yk-6Y for ged-emacs-devel@m.gmane.org; Sun, 22 Jul 2018 10:08:46 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48364) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhF2J-0004YZ-DV for emacs-devel@gnu.org; Sun, 22 Jul 2018 10:08:39 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhF2E-0008DG-DQ for emacs-devel@gnu.org; Sun, 22 Jul 2018 10:08:35 -0400 Original-Received: from mail-wm0-x232.google.com ([2a00:1450:400c:c09::232]:53111) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhF2E-0008D8-55 for emacs-devel@gnu.org; Sun, 22 Jul 2018 10:08:30 -0400 Original-Received: by mail-wm0-x232.google.com with SMTP id o11-v6so13429739wmh.2 for ; Sun, 22 Jul 2018 07:08:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:mail-followup-to:mail-copies-to :gmane-reply-to-list:date:in-reply-to:message-id:mime-version :content-transfer-encoding; bh=NRAE7k+AyHmnKy3wRIqfTqujcBcOBghRN5ExfZVV58Y=; b=ZolukXIrB3OI/0ssyseNJF9p/eIsAZ7U+WPnVJVPKAn7ZHnTfxkJXOItBTWCSR61TW zHbN5Ao2dV2zVEJ4ciPGoI+Ad7bzU5scviFOs1WhoQE4dUx7vnlgXWVfavjDPwbF80Ii Gr6xLD74+aqn40B7KiiVi+q1HBwY50nYhm+g4vUKfa+rPWNIHVcf416rKp8R0t4F0mrQ Gd6dnzcnh8IaTr7qLBa/F1pc9ePoTx+cfuGqcXDETil6w9zYYzduqKizLC0TjapkID3U PiVwS7vwANK2GeX+Dz14pNefXY2rCRtZ/AvYJjgrLxhowqlWNQUI0IRQg5c/wHwzGU42 0l3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:mail-followup-to :mail-copies-to:gmane-reply-to-list:date:in-reply-to:message-id :mime-version:content-transfer-encoding; bh=NRAE7k+AyHmnKy3wRIqfTqujcBcOBghRN5ExfZVV58Y=; b=qpEpyeMx7aDchogEBSqHPazCX9wvxUFUcinMPntgX7SFsc1ZpWO91Q8u+4r0JO241q tRAB1VpG+++0f2OEm7iox6s6EkrzqXjUty/nDEyLZvCBVqThxKQzWp8+MBxJuS5gFNhk hT5r1w4yD3e6yGrKB2n9d39/mUYIi/FcTKJYPf34q5mxd0bhdEwg1FcIuvMkTZGYZSvg 1sZfUNjrE+gaPOwnX8L4TqCyGEbTdodd7u3mlrnQDe7ebWeBLwjOBqRczBS7Wb28PFdP VrCjotDTmyq8X6GPsXdotTp1+b83G46OvMhLgNUy1kFVv2KtPDTwrU2uEjIa7f5FwZ3D YPQg== X-Gm-Message-State: AOUpUlGmT2IFvjk5SnzTOa5WYeaFKlyLnx9KAZt8/ERrA+oIPeOt+Z24 10aIX08qLKNJwBnuuCObMlotZOjq X-Google-Smtp-Source: AAOMgpf26vEXJOrFd5oQLnP4GepClX5qME40e3cYJYSqfZvCr0H/l1Y8CFNGQlhfn9FhcSK7L9qhaw== X-Received: by 2002:a1c:700a:: with SMTP id l10-v6mr5487114wmc.90.1532268508587; Sun, 22 Jul 2018 07:08:28 -0700 (PDT) Original-Received: from rpluim-ubuntu (vav06-1-78-207-202-134.fbx.proxad.net. [78.207.202.134]) by smtp.gmail.com with ESMTPSA id c5-v6sm6761881wrh.36.2018.07.22.07.08.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 22 Jul 2018 07:08:27 -0700 (PDT) Mail-Followup-To: emacs-devel@gnu.org Mail-Copies-To: never Gmane-Reply-To-List: yes In-Reply-To: (Lars Ingebrigtsen's message of "Sun, 22 Jul 2018 12:59:30 +0200") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::232 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:227669 Archived-At: Lars Ingebrigtsen writes: > I was thinking that the `nsm-verify-connection' call sites would > reconnect that function said "go ahead" and the process was dead. Which > is basically if it returns non-nil, I guess, so the return value of that > function doesn't have to change. Is this the kind of change you=CA=BCre thinking of? diff --git i/lisp/net/network-stream.el w/lisp/net/network-stream.el index a0589e25a4..dbaf719f41 100644 --- i/lisp/net/network-stream.el +++ w/lisp/net/network-stream.el @@ -383,7 +383,7 @@ network-stream-get-response =20 (declare-function open-tls-stream "tls" (name buffer host port)) =20 -(defun network-stream-open-tls (name buffer host service parameters) +(defun network-stream-open-tls (name buffer host service parameters &optio= nal retry) (with-current-buffer buffer (let* ((start (point-max)) (stream @@ -398,10 +398,14 @@ network-stream-open-tls ;; Check certificate validity etc. (when (and (gnutls-available-p) stream) (setq stream (nsm-verify-connection stream host service))) - (if (null stream) - (list nil nil nil 'plain) + (cond ((null stream) + (list nil nil nil 'plain)) ;; If we're using tls.el, we have to delete the output from ;; openssl/gnutls-cli. + ((and (not retry) (not (process-live-p))) + (message "Initial connect failed, retrying") + (network-stream-open-tls name buffer host service parameter= s t)) + (t (when (and (not (gnutls-available-p)) eoc) (network-stream-get-response stream start eoc) @@ -415,7 +419,7 @@ network-stream-open-tls (list stream (network-stream-get-response stream start eoc) (network-stream-command stream capability-command e= o-capa) - 'tls))))))) + 'tls)))))))) =20 (declare-function format-spec "format-spec" (format spec)) (declare-function format-spec-make "format-spec" (&rest pairs))