guix_mirror_bot pushed a commit to branch master
in repository guix.
commit b5f3c664835d8528e4a66bf2ecb7083f774993d8
Author: Ludovic Courtès <[email protected]>
AuthorDate: Fri Oct 9 18:16:29 2026 +0200
gnu: libgit2: Ensure ‘git_remote_disconnect’ closes sockets.
This fixes a file descriptor leak observed in long-running processes such as
Cuirass: the finalizers of <remote> objects, which would close the sockets,
would run too infrequently, leading to a leak of the underlying file
descriptors.
* gnu/packages/patches/libgit2-fix-remote-fd-leak.patch: New file.
* gnu/packages/version-control.scm (libgit2-1.9.7)[replacement]: New field.
(libgit2-1.9/fixed): New variable.
Fixes: guix/cuirass#153
Signed-off-by: Ludovic Courtès <[email protected]>
Merges: #11744
---
.../patches/libgit2-fix-remote-fd-leak.patch | 29 ++++++++++++++++++++++
gnu/packages/version-control.scm | 10 ++++++++
2 files changed, 39 insertions(+)
diff --git a/gnu/packages/patches/libgit2-fix-remote-fd-leak.patch
b/gnu/packages/patches/libgit2-fix-remote-fd-leak.patch
new file mode 100644
index 00000000000..17cbf87ce99
--- /dev/null
+++ b/gnu/packages/patches/libgit2-fix-remote-fd-leak.patch
@@ -0,0 +1,29 @@
+Fixes a bug whereby ‘git_remote_disconnect’ would not actually close the
+socket for the connection to the remote; instead one would have to call
+‘git_remote_free’ to make that happen.
+
+Upstream pull request: https://github.com/libgit2/libgit2/pull/7372
+Upstream bug report: https://github.com/libgit2/libgit2/issues/7356
+
+--- a/src/libgit2/transports/http.c
++++ b/src/libgit2/transports/http.c
+@@ -729,6 +729,10 @@ static int http_close(git_smart_subtransport *t)
+ git_net_url_dispose(&transport->server.url);
+ git_net_url_dispose(&transport->proxy.url);
+
++ /* The call below closes associated file descriptors. */
++ git_http_client_free(transport->http_client);
++ transport->http_client = NULL;
++
+ return 0;
+ }
+
+@@ -736,8 +740,6 @@ static void http_free(git_smart_subtransport *t)
+ {
+ http_subtransport *transport = GIT_CONTAINER_OF(t, http_subtransport,
parent);
+
+- git_http_client_free(transport->http_client);
+-
+ http_close(t);
+ git__free(transport);
+ }
diff --git a/gnu/packages/version-control.scm b/gnu/packages/version-control.scm
index 86d42b604cc..486a9a0bb4c 100644
--- a/gnu/packages/version-control.scm
+++ b/gnu/packages/version-control.scm
@@ -1453,6 +1453,7 @@ other git-like projects such as @code{libgit2}.")
"deps/pcre2"
"deps/winhttp"
"deps/zlib"))))))
+ (replacement libgit2-1.9/fixed)
(build-system cmake-build-system)
(outputs '("out" "debug"))
(arguments
@@ -1496,6 +1497,15 @@ write native speed custom Git applications in any
language with bindings.")
;; GPLv2 with linking exception
(license license:gpl2)))
+(define-public libgit2-1.9/fixed
+ (package
+ (inherit libgit2-1.9)
+ (source
+ (origin
+ (inherit (package-source libgit2-1.9))
+ (patches (append (origin-patches (package-source libgit2-1.9))
+ (search-patches
"libgit2-fix-remote-fd-leak.patch")))))))
+
(define-public libgit2-1.8
(package
(inherit libgit2-1.9)