pkgsrc-Changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
CVS commit: pkgsrc/net/libfetch/files
Module Name: pkgsrc
Committed By: wiz
Date: Thu Apr 16 08:28:21 UTC 2026
Modified Files:
pkgsrc/net/libfetch/files: common.c
Log Message:
libfetch: reduce diffs to src
revision 1.5
date: 2023-12-29 01:55:46 +0100; author: christos; state: Exp; lines: +19 -12; commitid: OCNaAvNzW7KWqiSE;
PR/57179: Christof Meerwald: Fix bugs in fetch_cache_{get,put}.
revision 1.7
date: 2024-02-02 23:19:05 +0100; author: christos; state: Exp; lines: +95 -17; commitid: WGGFqVnnZpItpUWE;
Sync with pkgsrc and try to fix more memory corruption from PR/57179.
To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 pkgsrc/net/libfetch/files/common.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: pkgsrc/net/libfetch/files/common.c
diff -u pkgsrc/net/libfetch/files/common.c:1.34 pkgsrc/net/libfetch/files/common.c:1.35
--- pkgsrc/net/libfetch/files/common.c:1.34 Thu Apr 16 08:20:45 2026
+++ pkgsrc/net/libfetch/files/common.c Thu Apr 16 08:28:21 2026
@@ -1,4 +1,4 @@
-/* $NetBSD: common.c,v 1.34 2026/04/16 08:20:45 wiz Exp $ */
+/* $NetBSD: common.c,v 1.35 2026/04/16 08:28:21 wiz Exp $ */
/*-
* Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
* Copyright (c) 2008, 2010 Joerg Sonnenberger <joerg%NetBSD.org@localhost>
@@ -374,7 +374,9 @@ fetch_cache_get(const struct url *url, i
{
conn_t *conn, *last_conn = NULL;
- for (conn = connection_cache; conn; conn = conn->next_cached) {
+ for (conn = connection_cache; conn; last_conn = conn,
+ conn = conn->next_cached)
+ {
if (conn->cache_url->port == url->port &&
strcmp(conn->cache_url->scheme, url->scheme) == 0 &&
strcmp(conn->cache_url->host, url->host) == 0 &&
@@ -401,8 +403,8 @@ fetch_cache_get(const struct url *url, i
void
fetch_cache_put(conn_t *conn, int (*closecb)(conn_t *))
{
- conn_t *iter, *last;
- int global_count, host_count;
+ conn_t *iter, *last, *oiter;
+ int global_count, host_count, added;
if (conn->cache_url == NULL || cache_global_limit == 0) {
(*closecb)(conn);
@@ -411,20 +413,28 @@ fetch_cache_put(conn_t *conn, int (*clos
global_count = host_count = 0;
last = NULL;
- for (iter = connection_cache; iter;
- last = iter, iter = iter->next_cached) {
+ for (iter = connection_cache; iter; ) {
++global_count;
- if (strcmp(conn->cache_url->host, iter->cache_url->host) == 0)
+ added = !strcmp(conn->cache_url->host, iter->cache_url->host);
+ if (added)
++host_count;
if (global_count < cache_global_limit &&
- host_count < cache_per_host_limit)
- continue;
- --global_count;
- if (last != NULL)
- last->next_cached = iter->next_cached;
- else
- connection_cache = iter->next_cached;
- (*iter->cache_close)(iter);
+ host_count < cache_per_host_limit) {
+ oiter = NULL;
+ last = iter;
+ } else {
+ --global_count;
+ if (added)
+ --host_count;
+ if (last != NULL)
+ last->next_cached = iter->next_cached;
+ else
+ connection_cache = iter->next_cached;
+ oiter = iter;
+ }
+ iter = iter->next_cached;
+ if (oiter)
+ (*oiter->cache_close)(oiter);
}
conn->cache_close = closecb;
Home |
Main Index |
Thread Index |
Old Index