From owner-freebsd-ports@freebsd.org Mon Feb 22 01:24:58 2016 Return-Path: Delivered-To: freebsd-ports@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 104ADAAFBD4 for ; Mon, 22 Feb 2016 01:24:58 +0000 (UTC) (envelope-from dave@flaterco.com) Received: from nupi.pair.com (nupi.pair.com [209.68.5.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E30D51E17; Mon, 22 Feb 2016 01:24:57 +0000 (UTC) (envelope-from dave@flaterco.com) Received: from [192.168.1.9] (pool-173-73-218-90.washdc.fios.verizon.net [173.73.218.90]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by nupi.pair.com (Postfix) with ESMTPSA id A0A8D4B0BB; Sun, 21 Feb 2016 20:24:55 -0500 (EST) Subject: Re: xtide 2.15 on FreeBSD-current amd64 To: Manfred Antar References: <86A01DE5-6592-4F9C-A224-F870F0C5517B@pozo.com> <56C9BD0E.7070301@flaterco.com> <89BBBB54-8BF1-4E61-A426-0B8D30DDE654@pozo.com> Cc: vanilla@FreeBSD.org, FreeBSD Ports ML From: David Flater Message-ID: <56CA6368.4030304@flaterco.com> Date: Sun, 21 Feb 2016 20:24:56 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <89BBBB54-8BF1-4E61-A426-0B8D30DDE654@pozo.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Feb 2016 01:24:58 -0000 On 02/21/2016 11:58 AM, Manfred Antar wrote: > Same error in syslog CANT_GET_SOCKET. Please test this patch against the xttpd of xtide-2.15. DWF Index: xttpd.cc =================================================================== --- xttpd.cc (revision 6265) +++ xttpd.cc (working copy) @@ -258,7 +258,21 @@ Global::xperror ("setsockopt"); } } - bool bound = (bind(s,(sockaddr *)&addr,sizeof(addr))==0); + + // 2016-02-21 Manfred Antar reported "bind: Invalid argument" occurring on + // FreeBSD and OS X as a regression from 2.14 when trying to bind port + // 8080, with or without an explicit address. The only change that should + // have been visible to bind is that the size argument got bigger. The + // FreeBSD man page for bind states that EINVAL can be raised if "the + // addrlen argument is not a valid length for the address family." I guess + // this means that apps making use of sockaddr_storage are supposed to lie + // about the length. The linux man page similarly states that EINVAL can + // be raised if "the addrlen is wrong" but the problem does not reproduce + // with my libc. + const socklen_t addrlen (addr.ss_family==AF_INET6 ? sizeof(sockaddr_in6) + : sizeof(sockaddr_in)); + + bool bound = (bind(s,(sockaddr *)&addr,addrlen)==0); int yerrno = errno; if (!bound && addr.ss_family == AF_INET6) { @@ -288,7 +302,7 @@ for (unsigned magic=4; !bound && magic>0; --magic) { ((sockaddr_in6 *)&addr)->sin6_scope_id = magic; - bound = (bind(s,(sockaddr *)&addr,sizeof(addr))==0); + bound = (bind(s,(sockaddr *)&addr,addrlen)==0); } } // Report the error from the first failure so that it won't be obscured by