NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: bin/59865: ftp should not set socket send/receive buffers unless told to
The following reply was made to PR bin/59865; it has been noted by GNATS.
From: mlelstv%serpens.de@localhost (Michael van Elst)
To: gnats-bugs%netbsd.org@localhost
Cc:
Subject: Re: bin/59865: ftp should not set socket send/receive buffers unless told to
Date: Sat, 27 Dec 2025 13:06:32 -0000 (UTC)
gnats-admin%netbsd.org@localhost writes:
> > From: mlelstv%serpens.de@localhost (Michael van Elst)
> > N.B. configuring a socket buffer size and using the same value for
> > the size of I/O operations, as done by ftp, isn't optimal either. But
> > that's a different issue.
>
> Yes, absolutely.
I'm currently limiting the I/O buffer to 128kB as a compromise between
file I/O and network buffer usage:
Index: usr.bin/ftp/fetch.c
===================================================================
RCS file: /cvsroot/src/usr.bin/ftp/fetch.c,v
retrieving revision 1.242
diff -p -u -r1.242 fetch.c
--- usr.bin/ftp/fetch.c 29 Nov 2024 04:31:57 -0000 1.242
+++ usr.bin/ftp/fetch.c 27 Dec 2025 13:00:19 -0000
@@ -1697,10 +1697,12 @@ fetch_url(const char *url, const char *p
oldint = xsignal(SIGINT, aborthttp);
assert(rcvbuf_size > 0);
- if ((size_t)rcvbuf_size > bufsize) {
+ if ((size_t)rcvbuf_size != bufsize) {
if (xferbuf)
(void)free(xferbuf);
bufsize = rcvbuf_size;
+ if (bufsize > 128 * 1024)
+ bufsize = 128 * 1024;
xferbuf = ftp_malloc(bufsize);
}
Index: usr.bin/ftp/ftp.c
===================================================================
RCS file: /cvsroot/src/usr.bin/ftp/ftp.c,v
retrieving revision 1.179
diff -p -u -r1.179 ftp.c
--- usr.bin/ftp/ftp.c 6 Dec 2025 06:20:23 -0000 1.179
+++ usr.bin/ftp/ftp.c 27 Dec 2025 13:00:19 -0000
@@ -1085,10 +1085,12 @@ recvrequest(const char *cmd, char *volat
preserve = 0;
}
assert(rcvbuf_size > 0);
- if ((size_t)rcvbuf_size > bufsize) {
+ if ((size_t)rcvbuf_size != bufsize) {
if (buf)
(void)free(buf);
bufsize = rcvbuf_size;
+ if (bufsize > 128 * 1024)
+ bufsize = 128 * 1024;
buf = ftp_malloc(bufsize);
}
Home |
Main Index |
Thread Index |
Old Index