From owner-freebsd-threads@freebsd.org Wed Jan 20 07:32:01 2016 Return-Path: Delivered-To: freebsd-threads@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 70D6FA8944F for ; Wed, 20 Jan 2016 07:32:01 +0000 (UTC) (envelope-from kostikbel@gmail.com) 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 57BC715BB for ; Wed, 20 Jan 2016 07:32:01 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: by mailman.ysv.freebsd.org (Postfix) id 5502CA8944D; Wed, 20 Jan 2016 07:32:01 +0000 (UTC) Delivered-To: threads@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 547ADA8944B; Wed, 20 Jan 2016 07:32:01 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C6D6C15B5; Wed, 20 Jan 2016 07:32:00 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id u0K7VtTp043835 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Wed, 20 Jan 2016 09:31:55 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua u0K7VtTp043835 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id u0K7VtE8043834; Wed, 20 Jan 2016 09:31:55 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 20 Jan 2016 09:31:55 +0200 From: Konstantin Belousov To: Boris Astardzhiev Cc: Jilles Tjoelker , net@freebsd.org, threads@freebsd.org Subject: Re: Does FreeBSD have sendmmsg or recvmmsg system calls? Message-ID: <20160120073154.GB3942@kib.kiev.ua> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jan 2016 07:32:01 -0000 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 ? > + > + if (vlen > VLEN_MAX) > + vlen = VLEN_MAX; Why is this restriction needed ? > + > + 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. > + if (rcvd != 0) { > + /* We've received messages. Let caller know. */ > + errno = 0; This cleaning is not needed as well. For successfull functions returns, errno value is undefined. > + return (rcvd); > + } > + return (-1); > + } > + > + /* Save received bytes */ > + msgvec[i].msg_len = ret; > + Extra empty line. > + rcvd++; > + } > + > + return (rcvd); > +}