From owner-freebsd-net@freebsd.org Wed Jan 20 10:30:56 2016 Return-Path: Delivered-To: freebsd-net@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AAA7AA89682 for ; Wed, 20 Jan 2016 10:30:56 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org [IPv6:2001:1900:2254:206a::50:5]) by mx1.freebsd.org (Postfix) with ESMTP id 94C381D94 for ; Wed, 20 Jan 2016 10:30:56 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: by mailman.ysv.freebsd.org (Postfix) id 91AF6A8967F; Wed, 20 Jan 2016 10:30:56 +0000 (UTC) Delivered-To: net@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9121CA8967D; Wed, 20 Jan 2016 10:30:56 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail105.syd.optusnet.com.au (mail105.syd.optusnet.com.au [211.29.132.249]) by mx1.freebsd.org (Postfix) with ESMTP id 58AEE1D92; Wed, 20 Jan 2016 10:30:55 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from c211-30-166-197.carlnfd1.nsw.optusnet.com.au (c211-30-166-197.carlnfd1.nsw.optusnet.com.au [211.30.166.197]) by mail105.syd.optusnet.com.au (Postfix) with ESMTPS id CF54910471B6; Wed, 20 Jan 2016 21:30:45 +1100 (AEDT) Date: Wed, 20 Jan 2016 21:30:44 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Konstantin Belousov cc: Boris Astardzhiev , threads@freebsd.org, Jilles Tjoelker , net@freebsd.org Subject: Re: Does FreeBSD have sendmmsg or recvmmsg system calls? In-Reply-To: <20160120073154.GB3942@kib.kiev.ua> Message-ID: <20160120205544.Q2305@besplex.bde.org> References: <20160113080349.GC72455@kib.kiev.ua> <20160116195657.GJ3942@kib.kiev.ua> <20160116202534.GK3942@kib.kiev.ua> <20160117211853.GA37847@stack.nl> <20160118044826.GS3942@kib.kiev.ua> <20160118140811.GW3942@kib.kiev.ua> <20160120073154.GB3942@kib.kiev.ua> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=R4L+YolX c=1 sm=1 tr=0 a=KA6XNC2GZCFrdESI5ZmdjQ==:117 a=PO7r1zJSAAAA:8 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=JzwRw_2MAAAA:8 a=kj9zAlcOel0A:10 a=FZoMsACIJPzh2gu83OkA:9 a=CjuIK1q_8ugA:10 X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jan 2016 10:30:56 -0000 On Wed, 20 Jan 2016, Konstantin Belousov wrote: > On Tue, Jan 19, 2016 at 01:58:27PM +0200, Boris Astardzhiev wrote: >> +int >> +recvmmsg(int s, struct mmsghdr *msgvec, unsigned int vlen, int flags) >> +{ >> + int i, ret, rcvd; > Shouldn't i and rcvd be unsigned as well ? Shouldn't return value > also be unsigned ? None of the above. Plain recvmsg() returns ssize_t and its len arg has type size_t. That is excessively typedefed and excessively large with 64-bit ssize_t, but it is silly for the multiple-message variant to use smaller types. Otherwise, all the integer types should be int. recvmsg() is still declared in syscalls.master as returning int, but it seems to be correct internallly. It is like read() and returns ssize_t in td_retval[0]. No wrong prototypes seem to be generated from the wrong retun types in syscalls.master. >> + rcvd = 0; >> + for (i = 0; i < vlen; i++) { >> + errno = 0; >> + ret = __sys_recvmsg(s, &msgvec[i].msg_hdr, flags); >> + if (ret < 0 || errno != 0) { > I do not see why do you need to clear errno before, and then do this test. > Just check ret == -1, in which case errno was set from the immediate syscall. The errno method (and not checking ret at all) is best if for syscalls that return -1 for a non-error. It is not needed here. Bruce