unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#73861] [PATCH] git: Add server connection and read timeouts.
@ 2024-10-18 12:52 Ludovic Courtès
  2024-10-18 14:34 ` Maxim Cournoyer
  0 siblings, 1 reply; 3+ messages in thread
From: Ludovic Courtès @ 2024-10-18 12:52 UTC (permalink / raw)
  To: 73861
  Cc: Ludovic Courtès, Christopher Baines, Josselin Poiret,
	Ludovic Courtès, Mathieu Othacehe, Simon Tournier,
	Tobias Geerinckx-Rice

Fixes <https://issues.guix.gnu.org/71818>.

* guix/git.scm (set-git-timeouts): New procedure.
(update-cached-checkout): Add #:connection-timeout and #:read-timeout.
Call ‘set-git-timeouts’.

Change-Id: Ibbd4fc6104ce66afed880b3975c129abbc2ab755
---
 guix/git.scm | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/guix/git.scm b/guix/git.scm
index 48a962089d..410cd4c153 100644
--- a/guix/git.scm
+++ b/guix/git.scm
@@ -206,6 +206,19 @@ (define GITERR_HTTP
         (module-ref errors 'GITERR_HTTP)
         34)))
 
+(define (set-git-timeouts connection-timeout read-timeout)
+  "Instruct Guile-Git to honor the given CONNECTION-TIMEOUT and READ-TIMEOUT
+when talking to remote Git servers.
+
+If one of them is #f, the corresponding default setting is kept unchanged."
+  ;; 'set-server-timeout!' & co. were added in Guile-Git 0.9.0.
+  (when (and (defined? 'set-server-connection-timeout!)
+             connection-timeout)
+    (set-server-connection-timeout! connection-timeout))
+  (when (and (defined? 'set-server-timeout!)
+             read-timeout)
+    (set-server-timeout! read-timeout)))
+
 (define (clone* url directory)
   "Clone git repository at URL into DIRECTORY.  Upon failure,
 make sure no empty directory is left behind."
@@ -512,6 +525,8 @@ (define (maybe-run-git-gc directory)
 
 (define* (update-cached-checkout url
                                  #:key
+                                 (connection-timeout 30000)
+                                 (read-timeout 45000)
                                  (ref '())
                                  recursive?
                                  (check-out? #t)
@@ -533,7 +548,12 @@ (define* (update-cached-checkout url
 When RECURSIVE? is true, check out submodules as well, if any.
 
 When CHECK-OUT? is true, reset the cached working tree to REF; otherwise leave
-it unchanged."
+it unchanged.
+
+Wait for up to CONNECTION-TIMEOUT milliseconds when establishing connection to
+the remote server, and for up to READ-TIMEOUT milliseconds when reading from
+it.  When zero, use the system defaults for these timeouts; when false, leave
+current settings unchanged."
   (define (cache-entries directory)
     (filter-map (match-lambda
                   ((or "." "..")
@@ -555,6 +575,7 @@ (define* (update-cached-checkout url
       (_ ref)))
 
   (with-libgit2
+   (set-git-timeouts connection-timeout read-timeout)
    (let* ((cache-exists? (openable-repository? cache-directory))
           (repository    (if cache-exists?
                              (repository-open cache-directory)

base-commit: d95588242c605fbb72e25fe36a0903a1538e9018
-- 
2.46.0





^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [bug#73861] [PATCH] git: Add server connection and read timeouts.
  2024-10-18 12:52 [bug#73861] [PATCH] git: Add server connection and read timeouts Ludovic Courtès
@ 2024-10-18 14:34 ` Maxim Cournoyer
  2024-10-21 22:30   ` bug#73861: " Ludovic Courtès
  0 siblings, 1 reply; 3+ messages in thread
From: Maxim Cournoyer @ 2024-10-18 14:34 UTC (permalink / raw)
  To: Ludovic Courtès
  Cc: Josselin Poiret, 73861, Simon Tournier, Mathieu Othacehe,
	Tobias Geerinckx-Rice, Christopher Baines

Hi,

Ludovic Courtès <ludo@gnu.org> writes:

> Fixes <https://issues.guix.gnu.org/71818>.
>
> * guix/git.scm (set-git-timeouts): New procedure.
> (update-cached-checkout): Add #:connection-timeout and #:read-timeout.
> Call ‘set-git-timeouts’.
>
> Change-Id: Ibbd4fc6104ce66afed880b3975c129abbc2ab755

Neat! LGTM.

Reviewed-by: Maxim Cournoyer <maxim.cournoyer@gmail>

-- 
Thanks,
Maxim




^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#73861: [PATCH] git: Add server connection and read timeouts.
  2024-10-18 14:34 ` Maxim Cournoyer
@ 2024-10-21 22:30   ` Ludovic Courtès
  0 siblings, 0 replies; 3+ messages in thread
From: Ludovic Courtès @ 2024-10-21 22:30 UTC (permalink / raw)
  To: Maxim Cournoyer
  Cc: Josselin Poiret, Simon Tournier, Mathieu Othacehe,
	Tobias Geerinckx-Rice, 73861-done, Christopher Baines

Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:

> Ludovic Courtès <ludo@gnu.org> writes:
>
>> Fixes <https://issues.guix.gnu.org/71818>.
>>
>> * guix/git.scm (set-git-timeouts): New procedure.
>> (update-cached-checkout): Add #:connection-timeout and #:read-timeout.
>> Call ‘set-git-timeouts’.
>>
>> Change-Id: Ibbd4fc6104ce66afed880b3975c129abbc2ab755
>
> Neat! LGTM.
>
> Reviewed-by: Maxim Cournoyer <maxim.cournoyer@gmail>

Pushed as 8bd013011ddde259c0dd0334847ce31a63263962, thanks!




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-10-21 22:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-18 12:52 [bug#73861] [PATCH] git: Add server connection and read timeouts Ludovic Courtès
2024-10-18 14:34 ` Maxim Cournoyer
2024-10-21 22:30   ` bug#73861: " Ludovic Courtès

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).