Module Name:    src
Committed By:   lukem
Date:           Thu Jun  3 10:11:00 UTC 2021

Modified Files:
        src/usr.bin/ftp: ftp.c

Log Message:
set SO_KEEPALIVE on control connection

Attempt to prevent timeouts of the control connection by setting SO_KEEPALIVE.
This matches the equivalent behaviour in ftpd.

Note: This is a much simpler change than adding a background polling event
to invoke "STAT" (or "NOOP") on the control connection during a transfer.
(It's unclear from RFC 959 whether "NOOP" is even permitted during a transfer).

PR bin/56129


To generate a diff of this commit:
cvs rdiff -u -r1.171 -r1.172 src/usr.bin/ftp/ftp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/ftp/ftp.c
diff -u src/usr.bin/ftp/ftp.c:1.171 src/usr.bin/ftp/ftp.c:1.172
--- src/usr.bin/ftp/ftp.c:1.171	Wed Jan  6 04:43:14 2021
+++ src/usr.bin/ftp/ftp.c	Thu Jun  3 10:11:00 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ftp.c,v 1.171 2021/01/06 04:43:14 lukem Exp $	*/
+/*	$NetBSD: ftp.c,v 1.172 2021/06/03 10:11:00 lukem Exp $	*/
 
 /*-
  * Copyright (c) 1996-2021 The NetBSD Foundation, Inc.
@@ -92,7 +92,7 @@
 #if 0
 static char sccsid[] = "@(#)ftp.c	8.6 (Berkeley) 10/27/94";
 #else
-__RCSID("$NetBSD: ftp.c,v 1.171 2021/01/06 04:43:14 lukem Exp $");
+__RCSID("$NetBSD: ftp.c,v 1.172 2021/06/03 10:11:00 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -280,6 +280,11 @@ hookup(const char *host, const char *por
 		goto bad;
 	}
 
+	if (setsockopt(s, SOL_SOCKET, SO_KEEPALIVE,
+			(void *)&on, sizeof(on)) == -1) {
+		DWARN("setsockopt %s (ignored)", "SO_KEEPALIVE");
+	}
+
 	if (setsockopt(s, SOL_SOCKET, SO_OOBINLINE,
 			(void *)&on, sizeof(on)) == -1) {
 		DWARN("setsockopt %s (ignored)", "SO_OOBINLINE");

Reply via email to