From owner-svn-src-head@FreeBSD.ORG Sun Jun 28 11:28:14 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9A647106564A; Sun, 28 Jun 2009 11:28:14 +0000 (UTC) (envelope-from phk@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 87AAE8FC1E; Sun, 28 Jun 2009 11:28:14 +0000 (UTC) (envelope-from phk@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n5SBSEaW010430; Sun, 28 Jun 2009 11:28:14 GMT (envelope-from phk@svn.freebsd.org) Received: (from phk@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n5SBSErp010426; Sun, 28 Jun 2009 11:28:14 GMT (envelope-from phk@svn.freebsd.org) Message-Id: <200906281128.n5SBSErp010426@svn.freebsd.org> From: Poul-Henning Kamp Date: Sun, 28 Jun 2009 11:28:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r195134 - in head/sys: dev/ath/ath_hal/ar5416 kern sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Jun 2009 11:28:15 -0000 Author: phk Date: Sun Jun 28 11:28:14 2009 New Revision: 195134 URL: http://svn.freebsd.org/changeset/base/195134 Log: There are a number of ways an application can check if there are inbound data waiting on a filedescriptor, such as a pipe or a socket, for instance by using select(2), poll(2), kqueue(2), ioctl(FIONREAD) etc. But we have no way of finding out if written data have yet to be disposed of, for instance, transmitted (and ack'ed!) to some remote host, or read by the applicantion at the far end of the pipe. The closest we get, is calling shutdown(2) on a TCP socket in non-blocking mode, but this has the undesirable sideeffect of preventing future communication. Add a complement to FIONREAD, called FIONWRITE, which returns the number of bytes not yet properly disposed of. Implement it for all sockets. Background: A HTTP server will want to time out connections, if no new request arrives within a certain period after the last transmitted response has actually been sent (and ack'ed). For a busy HTTP server, this timeout can be subsecond duration. In order to signal to a load-balancer that the connection is truly dead, TCP_RST will be the preferred method, as this avoids the need for a RTT delay for FIN handshaking, with a client which, surprisingly often, no longer at the remote IP number. If a slow, distant client is being served a response which is big enough to fill the window, but small enough to fit in the socket buffer, the write(2) call will return immediately. If the session timeout is armed at that time, all bytes in the response may not have been transmitted by the time it fires. FIONWRITE allows the timeout to check that no data is outstanding on the connection, before it TCP_RST's it. Input & Idea from: rwatson Approved by: re (kib) Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c head/sys/kern/sys_socket.c head/sys/sys/filio.h Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c ============================================================================== --- head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c Sun Jun 28 10:30:53 2009 (r195133) +++ head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c Sun Jun 28 11:28:14 2009 (r195134) @@ -124,7 +124,7 @@ ar5416Reset(struct ath_hal *ah, HAL_OPMO if (!ar5416SetPowerMode(ah, HAL_PM_AWAKE, AH_TRUE)) { HALDEBUG(ah, HAL_DEBUG_ANY, "%s: chip did not wakeup\n", __func__); - FAIL(HAL_EIO); + // FAIL(HAL_EIO); } /* Modified: head/sys/kern/sys_socket.c ============================================================================== --- head/sys/kern/sys_socket.c Sun Jun 28 10:30:53 2009 (r195133) +++ head/sys/kern/sys_socket.c Sun Jun 28 11:28:14 2009 (r195134) @@ -169,6 +169,11 @@ soo_ioctl(struct file *fp, u_long cmd, v *(int *)data = so->so_rcv.sb_cc; break; + case FIONWRITE: + /* Unlocked read. */ + *(int *)data = so->so_snd.sb_cc; + break; + case FIOSETOWN: error = fsetown(*(int *)data, &so->so_sigio); break; Modified: head/sys/sys/filio.h ============================================================================== --- head/sys/sys/filio.h Sun Jun 28 10:30:53 2009 (r195133) +++ head/sys/sys/filio.h Sun Jun 28 11:28:14 2009 (r195134) @@ -55,6 +55,7 @@ struct fiodgname_arg { void *buf; }; #define FIODGNAME _IOW('f', 120, struct fiodgname_arg) /* get dev. name */ +#define FIONWRITE _IOR('f', 119, int) /* get # bytes (yet) to write */ /* Handle lseek SEEK_DATA and SEEK_HOLE for holey file knowledge. */ #define FIOSEEKDATA _IOWR('f', 97, off_t) /* SEEK_DATA */ #define FIOSEEKHOLE _IOWR('f', 98, off_t) /* SEEK_HOLE */