Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 4 Oct 2010 20:40:44 +0300
From:      Kostik Belousov <kostikbel@gmail.com>
To:        Hajimu UMEMOTO <ume@freebsd.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r211276 - head/lib/libc/net
Message-ID:  <20101004174044.GU2392@deviant.kiev.zoral.com.ua>
In-Reply-To: <yge62xivuv9.wl%ume@mahoroba.org>
References:  <201008130639.o7D6dsk1022779@svn.freebsd.org> <20101003184925.GA87647@deviant.kiev.zoral.com.ua> <yge62xivuv9.wl%ume@mahoroba.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--TegBI+r9roYdcP94
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Tue, Oct 05, 2010 at 12:30:02AM +0900, Hajimu UMEMOTO wrote:
> Hi,
>=20
> >>>>> On Sun, 3 Oct 2010 21:49:26 +0300
> >>>>> Kostik Belousov <kostikbel@gmail.com> said:
>=20
> kostikbel> I suspect there is some subtle issue with the commit present.
> kostikbel> When getprotobyname_r() is unable to find the protocol, it see=
ms
> kostikbel> that established behaviour is to return 0 and set *protoent to=
 NULL.
>=20
> The behavior you mentioned is questionable to me.  Though I cannot
> find the manpage of getprotobyname_r(3), there is following
> description in the manpage of gethostbyname_r(3) on CentOS:
>=20
> 	Glibc2 also has reentrant versions gethostbyname_r() and
> 	gethostbyname2_r().  These return 0 on success and non-zero on
> 	error.
>=20
> When getprotobyname_r(3) is unable to find the protocol, it should be
> treated as error, IMHO.  My intention is that when getprotobyname_r(3)
> ends up with error but errno is zero, the return code should be
> non-zero (-1).
>=20
> kostikbel> The getprotobyname_r() in HEAD and stable/8, when the protocol
> kostikbel> cannot be found, return whatever value was present in errno at=
 the time
> kostikbel> of the call.
>=20
> In anyway, errno should be cleared.  I've just committed to clear
> errno for each method dispatch.
>=20
> kostikbel> When run with the argument "tcp1" on Linux, I get
> kostikbel> 	Res 0 errno 0 Success pres (nil)
> kostikbel> On the recent FreeBSD I get
> kostikbel> 	Res 25 errno 25 Inappropriate ioctl for device pres 0x0
> kostikbel> (ENOTTY is from stdio).
>=20
> Now, it shows:
>=20
> 	Res -1 errno 22 Unknown error: 0 pres 0x0
>=20
> (When strerror(3) is called with 0 for its argument, it set errno to
> EINVAL.)

Yes, I saw that commit. And there is a software in wild that does expect
return value 0 and NULL returned pointer when protocol was not found,
as opposed to some processing error. The interpretation of non-zero
error code is "We did something wrong, or system configuration is wrong,
etc". While zero error code and NULL pointer is perceived as "Wrong
protocol name supplied".

Solaris uses different API, I think we better follow Linux if we
selected the Linux API variant.

--TegBI+r9roYdcP94
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (FreeBSD)

iEYEARECAAYFAkyqEZsACgkQC3+MBN1Mb4jaLQCg51fw0ir7iYv4G4ZTz8azNHgw
P1wAnAzvFVgqbS+dViZxbBFNlrEJMroz
=aFBi
-----END PGP SIGNATURE-----

--TegBI+r9roYdcP94--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20101004174044.GU2392>