Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F110666988
D23732.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D23732.diff
View Options
Index: head/contrib/tnftp/src/cmds.c
===================================================================
--- head/contrib/tnftp/src/cmds.c
+++ head/contrib/tnftp/src/cmds.c
@@ -2653,10 +2653,14 @@
goto usage;
}
- if (dir & RATE_PUT)
+ if (dir & RATE_PUT) {
sndbuf_size = size;
- if (dir & RATE_GET)
+ auto_sndbuf = 0;
+ }
+ if (dir & RATE_GET) {
rcvbuf_size = size;
+ auto_rcvbuf = 0;
+ }
fprintf(ttyout, "Socket buffer sizes: send %d, receive %d.\n",
sndbuf_size, rcvbuf_size);
code = 0;
Index: head/contrib/tnftp/src/ftp_var.h
===================================================================
--- head/contrib/tnftp/src/ftp_var.h
+++ head/contrib/tnftp/src/ftp_var.h
@@ -298,6 +298,8 @@
GLOBAL int sndbuf_size; /* socket send buffer size */
GLOBAL int rcvbuf_size; /* socket receive buffer size */
+GLOBAL int auto_sndbuf; /* flag: if != 0 then use auto sndbuf size */
+GLOBAL int auto_rcvbuf; /* flag: if != 0 then use auto rcvbuf size */
GLOBAL int macnum; /* number of defined macros */
GLOBAL struct macel macros[16];
Index: head/contrib/tnftp/src/main.c
===================================================================
--- head/contrib/tnftp/src/main.c
+++ head/contrib/tnftp/src/main.c
@@ -127,6 +127,9 @@
#include <locale.h>
#endif /* tnftp */
+#ifdef __FreeBSD__
+#include <sys/sysctl.h>
+#endif
#define GLOBAL /* force GLOBAL decls in ftp_var.h to be declared */
#include "ftp_var.h"
@@ -509,6 +512,13 @@
(void)xsignal(SIGUSR1, crankrate);
(void)xsignal(SIGUSR2, crankrate);
(void)xsignal(SIGWINCH, setttywidth);
+
+ auto_rcvbuf = ((sysctlbyname("net.inet.tcp.recvbuf_auto",
+ &auto_rcvbuf, &(size_t []){[0] = sizeof(int)}[0], NULL, 0) == 0) &&
+ auto_rcvbuf == 1);
+ auto_sndbuf = ((sysctlbyname("net.inet.tcp.sendbuf_auto",
+ &auto_sndbuf, &(size_t []){[0] = sizeof(int)}[0], NULL, 0) == 0) &&
+ auto_sndbuf == 1);
if (argc > 0) {
if (isupload) {
Index: head/contrib/tnftp/src/util.c
===================================================================
--- head/contrib/tnftp/src/util.c
+++ head/contrib/tnftp/src/util.c
@@ -1087,13 +1087,27 @@
sndbuf_size);
}
+#ifdef __FreeBSD__
+ DPRINTF("auto_rcvbuf = %d\n", auto_rcvbuf);
+ if (auto_sndbuf == 0) {
+#endif
if (setsockopt(sock, SOL_SOCKET, SO_SNDBUF,
(void *)&sndbuf_size, sizeof(sndbuf_size)) == -1)
warn("Unable to set sndbuf size %d", sndbuf_size);
+#ifdef __FreeBSD__
+ }
+#endif
+#ifdef __FreeBSD__
+ DPRINTF("auto_sndbuf = %d\n", auto_sndbuf);
+ if (auto_rcvbuf == 0) {
+#endif
if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF,
(void *)&rcvbuf_size, sizeof(rcvbuf_size)) == -1)
warn("Unable to set rcvbuf size %d", rcvbuf_size);
+#ifdef __FreeBSD__
+ }
+#endif
}
/*
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Feb 22, 4:29 PM (2 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16770532
Default Alt Text
D23732.diff (2 KB)
Attached To
Mode
D23732: Fix poor performance of ftp(1) due to small SO_SNDBUF and SO_RCVBUF
Attached
Detach File
Event Timeline
Log In to Comment