Commit 7c877edc authored by Julien Cristau's avatar Julien Cristau
Browse files

Bug 1821513 - patch mercurial debian package to make http.timeout option work...

Bug 1821513 - patch mercurial debian package to make http.timeout option work r=releng-reviewers,bhearsum a=release

Cherry-pick from https://www.mercurial-scm.org/repo/hg/rev/3bb7c56e8fe6

Differential Revision: https://phabricator.services.mozilla.com/D173274
parent 418e9cc7
Loading
Loading
Loading
Loading
+38 −0
Original line number Diff line number Diff line
# HG changeset patch
# User Julien Cristau <jcristau@mozilla.com>
# Date 1679408823 -3600
#      Tue Mar 21 15:27:03 2023 +0100
# Branch stable
# Node ID 3a889388b8f5e4fc884fd7eb6c5daf82056627e2
# Parent  411dc27fd9fd076d6a031a08fcaace659afe2fe3
url: don't ignore timeout for https connections

For http, we use the stdlib's HTTPConnection.connect which passes the
timeout down to socket.create_connection; for https, we override the
connect method but weren't handling the timeout, so connections could
hang for hours even with http.timeout set to low values.

diff --git a/mercurial/url.py b/mercurial/url.py
--- a/mercurial/url.py
+++ b/mercurial/url.py
@@ -404,17 +404,19 @@ if has_https:
             *args,
             **kwargs
         ):
             keepalive.HTTPConnection.__init__(self, host, port, *args, **kwargs)
             self.key_file = key_file
             self.cert_file = cert_file
 
         def connect(self):
-            self.sock = socket.create_connection((self.host, self.port))
+            self.sock = socket.create_connection(
+                (self.host, self.port), self.timeout
+            )
 
             host = self.host
             if self.realhostport:  # use CONNECT proxy
                 _generic_proxytunnel(self)
                 host = self.realhostport.rsplit(b':', 1)[0]
             self.sock = sslutil.wrapsocket(
                 self.sock,
                 self.key_file,
+1 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ deb11-mercurial:
            sed -i -e "s/__VERSION__/$(awk -F\" '$2 {print $2}' mercurial/__version__.py)-1.deb11moz1/" \
                         -e "s/__DATE__/$(date --rfc-2822)/" \
                         -e "s/__CODENAME__/bullseye/" debian/changelog
        patch: mercurial-timeout.diff

deb11-cmake:
    description: "cmake"
+2 −0
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ ub18-mercurial:
            sed -i -e "s/__VERSION__/$(awk -F\" '$2 {print $2}' mercurial/__version__.py)-1.ub18moz1/" \
                         -e "s/__DATE__/$(date --rfc-2822)/" \
                         -e "s/__CODENAME__/bionic/" debian/changelog
        patch: mercurial-timeout.diff

ub20-python-zstandard:
    description: "python-zstandard for Ubuntu focal"
@@ -98,3 +99,4 @@ ub20-mercurial:
            sed -i -e "s/__VERSION__/$(awk -F\" '$2 {print $2}' mercurial/__version__.py)-1.ub20moz1/" \
                         -e "s/__DATE__/$(date --rfc-2822)/" \
                         -e "s/__CODENAME__/focal/" debian/changelog
        patch: mercurial-timeout.diff