From owner-svn-src-head@FreeBSD.ORG Sun Dec 15 22:58:10 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 685C7DAB; Sun, 15 Dec 2013 22:58:10 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 3AAF81899; Sun, 15 Dec 2013 22:58:10 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id rBFMwAKl027970; Sun, 15 Dec 2013 22:58:10 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id rBFMw9ip027967; Sun, 15 Dec 2013 22:58:09 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201312152258.rBFMw9ip027967@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Sun, 15 Dec 2013 22:58:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r259430 - head/lib/libnv X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.17 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, 15 Dec 2013 22:58:10 -0000 Author: pjd Date: Sun Dec 15 22:58:09 2013 New Revision: 259430 URL: http://svnweb.freebsd.org/changeset/base/259430 Log: MFp4 @1189139: Get rid of the msg_peek() function, which has a problem. If there was less data in the socket buffer than requested by the caller, the function would busy loop, as select(2) will always return immediately. We can just receive nvlhdr now, because some time ago we splitted receive of data from the receive of descriptors. MFC after: 1 week Modified: head/lib/libnv/msgio.c head/lib/libnv/msgio.h head/lib/libnv/nvlist.c Modified: head/lib/libnv/msgio.c ============================================================================== --- head/lib/libnv/msgio.c Sun Dec 15 22:52:18 2013 (r259429) +++ head/lib/libnv/msgio.c Sun Dec 15 22:58:09 2013 (r259430) @@ -113,30 +113,6 @@ fd_wait(int fd, bool doread) NULL, NULL); } -int -msg_peek(int sock, void *buf, size_t size) -{ - ssize_t done; - - PJDLOG_ASSERT(sock >= 0); - PJDLOG_ASSERT(size > 0); - - do { - fd_wait(sock, true); - done = recv(sock, buf, size, MSG_PEEK | MSG_WAITALL); - if (done == -1) { - if (errno == EAGAIN || errno == EINTR) - continue; - return (-1); - } else if (done == 0) { - errno = ENOTCONN; - return (-1); - } - } while (done != (ssize_t)size); - - return (0); -} - static int msg_recv(int sock, struct msghdr *msg) { Modified: head/lib/libnv/msgio.h ============================================================================== --- head/lib/libnv/msgio.h Sun Dec 15 22:52:18 2013 (r259429) +++ head/lib/libnv/msgio.h Sun Dec 15 22:58:09 2013 (r259430) @@ -38,8 +38,6 @@ struct cmsgcred; struct iovec; struct msghdr; -int msg_peek(int sock, void *buf, size_t size); - int cred_send(int sock); int cred_recv(int sock, struct cmsgcred *cred); Modified: head/lib/libnv/nvlist.c ============================================================================== --- head/lib/libnv/nvlist.c Sun Dec 15 22:52:18 2013 (r259429) +++ head/lib/libnv/nvlist.c Sun Dec 15 22:58:09 2013 (r259430) @@ -724,11 +724,11 @@ nvlist_recv(int sock) { struct nvlist_header nvlhdr; nvlist_t *nvl, *ret; + unsigned char *buf; size_t nfds, size; - void *buf; int serrno, *fds; - if (msg_peek(sock, &nvlhdr, sizeof(nvlhdr)) == -1) + if (buf_recv(sock, &nvlhdr, sizeof(nvlhdr)) == -1) return (NULL); if (!nvlist_check_header(&nvlhdr)) @@ -741,10 +741,12 @@ nvlist_recv(int sock) if (buf == NULL) return (NULL); + memcpy(buf, &nvlhdr, sizeof(nvlhdr)); + ret = NULL; fds = NULL; - if (buf_recv(sock, buf, size) == -1) + if (buf_recv(sock, buf + sizeof(nvlhdr), size - sizeof(nvlhdr)) == -1) goto out; if (nfds > 0) {