Page MenuHomeFreeBSD

D23732.diff
No OneTemporary

D23732.diff

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

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)

Event Timeline