diff options
author | Jeremie Courreges-Anglas <jca@cvs.openbsd.org> | 2016-09-03 15:00:49 +0000 |
---|---|---|
committer | Jeremie Courreges-Anglas <jca@cvs.openbsd.org> | 2016-09-03 15:00:49 +0000 |
commit | 323bad2bdec13f30767585aa613482e18732747d (patch) | |
tree | 31723bcbd24dafcdd5baa11bbdcb3bb7442bf28c /libexec | |
parent | dd69c196a21f3dbe7ba723612ac2d6f1262c528b (diff) |
Use a single "opt" variable for all setsockopt calls in getdatasock().
on = 65536;
if (setsockopt(... &on ...)
is slightly misleading.
Diffstat (limited to 'libexec')
-rw-r--r-- | libexec/ftpd/ftpd.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c index 1f99318a47d..a1d1998ffae 100644 --- a/libexec/ftpd/ftpd.c +++ b/libexec/ftpd/ftpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ftpd.c,v 1.222 2016/09/03 14:53:20 jca Exp $ */ +/* $OpenBSD: ftpd.c,v 1.223 2016/09/03 15:00:48 jca Exp $ */ /* $NetBSD: ftpd.c,v 1.15 1995/06/03 22:46:47 mycroft Exp $ */ /* @@ -1276,7 +1276,7 @@ done: static FILE * getdatasock(char *mode) { - int on = 1, s, t, tos, tries; + int opt, s, t, tries; if (data >= 0) return (fdopen(data, mode)); @@ -1284,8 +1284,9 @@ getdatasock(char *mode) s = monitor_socket(ctrl_addr.su_family); if (s < 0) goto bad; + opt = 1; if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, - &on, sizeof(on)) < 0) + &opt, sizeof(opt)) < 0) goto bad; /* anchor socket to avoid multi-homing problems */ data_source = ctrl_addr; @@ -1300,16 +1301,16 @@ getdatasock(char *mode) } sigprocmask (SIG_UNBLOCK, &allsigs, NULL); - tos = IPTOS_THROUGHPUT; + opt = IPTOS_THROUGHPUT; switch (ctrl_addr.su_family) { case AF_INET: - if (setsockopt(s, IPPROTO_IP, IP_TOS, &tos, - sizeof(int)) < 0) + if (setsockopt(s, IPPROTO_IP, IP_TOS, &opt, + sizeof(opt)) < 0) syslog(LOG_WARNING, "setsockopt (IP_TOS): %m"); break; case AF_INET6: - if (setsockopt(s, IPPROTO_IPV6, IPV6_TCLASS, &tos, - sizeof(int)) < 0) + if (setsockopt(s, IPPROTO_IPV6, IPV6_TCLASS, &opt, + sizeof(opt)) < 0) syslog(LOG_WARNING, "setsockopt (IPV6_TCLASS): %m"); break; } @@ -1319,11 +1320,11 @@ getdatasock(char *mode) * to set the send buffer size as well, but that may not be desirable * in heavy-load situations. */ - on = 1; - if (setsockopt(s, IPPROTO_TCP, TCP_NOPUSH, &on, sizeof(on)) < 0) + opt = 1; + if (setsockopt(s, IPPROTO_TCP, TCP_NOPUSH, &opt, sizeof(opt)) < 0) syslog(LOG_WARNING, "setsockopt (TCP_NOPUSH): %m"); - on = 65536; - if (setsockopt(s, SOL_SOCKET, SO_SNDBUF, &on, sizeof(on)) < 0) + opt = 65536; + if (setsockopt(s, SOL_SOCKET, SO_SNDBUF, &opt, sizeof(opt)) < 0) syslog(LOG_WARNING, "setsockopt (SO_SNDBUF): %m"); return (fdopen(s, mode)); |