Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 1 Oct 2016 23:40:59 -0400
From:      Alexander Kabaev <kabaev@gmail.com>
To:        Konstantin Belousov <kostikbel@gmail.com>
Cc:        Jilles Tjoelker <jilles@stack.nl>, Lewis Donzis <lew@perftech.com>, deischen@freebsd.org, freebsd-arch@freebsd.org
Subject:   Re: mq on kqueue broken after upgrade to FreeBSD 11
Message-ID:  <20161001234059.6f51310b@kan>
In-Reply-To: <20161001210722.GC38409@kib.kiev.ua>
References:  <8A6CD0D3-C4D5-40DF-B2AD-4C454CC88AD1@perftech.com> <20160930094544.GP38409@kib.kiev.ua> <19A6EEAA-C68E-4DAD-B98F-4D904734BD8B@perftech.com> <20160930152006.GS38409@kib.kiev.ua> <20160930184418.1047afc2@kan> <20161001092515.GW38409@kib.kiev.ua> <20161001201655.GA91457@stack.nl> <20161001210722.GC38409@kib.kiev.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
--Sig_/Dx6k8femPnHps78YWcQVe8b
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: quoted-printable

On Sun, 2 Oct 2016 00:07:22 +0300
Konstantin Belousov <kostikbel@gmail.com> wrote:

> On Sat, Oct 01, 2016 at 10:16:55PM +0200, Jilles Tjoelker wrote:
> > The idea is good, but perhaps call the function mq_getfd_np() to
> > clarify it returns a file descriptor. Also, the __ versions should
> > not be exported since they are not used outside the library (they
> > can be exported if and when needed). =20
>=20
>=20
> diff --git a/include/mqueue.h b/include/mqueue.h
> index 788d0a1..e1c0f27 100644
> --- a/include/mqueue.h
> +++ b/include/mqueue.h
> @@ -50,7 +50,9 @@ ssize_t	mq_timedreceive(mqd_t, char
> *__restrict, size_t, int	mq_timedsend(mqd_t, const char *,
> size_t, unsigned, const struct timespec *);
>  int	mq_unlink(const char *);
> -int	__mq_oshandle(mqd_t mqd);
> +#if __BSD_VISIBLE
> +int	mq_getfd_np(mqd_t mqd);
> +#endif /* __BSD_VISIBLE */
> =20
>  __END_DECLS
>  #endif
> diff --git a/include/time.h b/include/time.h
> index 14d6044..c172538 100644
> --- a/include/time.h
> +++ b/include/time.h
> @@ -194,6 +194,7 @@ char *timezone(int, int);	/* XXX XSI
> conflict */ void tzsetwall(void);
>  time_t timelocal(struct tm * const);
>  time_t timegm(struct tm * const);
> +int timer_oshandle_np(timer_t timerid);
>  #endif /* __BSD_VISIBLE */
> =20
>  #if __POSIX_VISIBLE >=3D 200809 || defined(_XLOCALE_H_)
> diff --git a/lib/librt/Symbol.map b/lib/librt/Symbol.map
> index 161bb76..fef3c15 100644
> --- a/lib/librt/Symbol.map
> +++ b/lib/librt/Symbol.map
> @@ -25,6 +25,11 @@ FBSD_1.0 {
>  	timer_getoverrun;
>  };
> =20
> +FBSD_1.5 {
> +	mq_getfd_np;
> +	timer_oshandle_np;
> +};
> +
>  FBSDprivate_1.0 {
>  	_aio_read;
>  	_aio_write;
> diff --git a/lib/librt/mq.c b/lib/librt/mq.c
> index 750e969..513fa72 100644
> --- a/lib/librt/mq.c
> +++ b/lib/librt/mq.c
> @@ -272,8 +272,9 @@ __mq_unlink(const char *path)
>  	return __sys_kmq_unlink(path);
>  }
> =20
> +#pragma weak mq_getfd_np
>  int
> -__mq_oshandle(mqd_t mqd)
> +mq_getfd_np(mqd_t mqd)
>  {
> =20
>  	return (mqd->oshandle);
> diff --git a/lib/librt/timer.c b/lib/librt/timer.c
> index 90269c2..b5f775c 100644
> --- a/lib/librt/timer.c
> +++ b/lib/librt/timer.c
> @@ -175,8 +175,9 @@ __timer_settime(timer_t timerid, int flags,
>  		flags, value, ovalue);
>  }
> =20
> +#pragma weak timer_oshandle_np
>  int
> -__timer_oshandle(timer_t timerid)
> +timer_oshandle_np(timer_t timerid)
>  {
> =20
>  	return (timerid->oshandle);
> diff --git a/tests/sys/mqueue/Makefile b/tests/sys/mqueue/Makefile
> index ce5033c..251c497 100644
> --- a/tests/sys/mqueue/Makefile
> +++ b/tests/sys/mqueue/Makefile
> @@ -10,8 +10,8 @@ CFLAGS+=3D	-I${SRCTOP}/tests
> =20
>  PROGS+=3D		mqtest1
>  PROGS+=3D		mqtest2
> -#PROGS+=3D		mqtest3
> -#PROGS+=3D		mqtest4
> +PROGS+=3D		mqtest3
> +PROGS+=3D		mqtest4
>  PROGS+=3D		mqtest5
> =20
>  LIBADD+=3D	rt
> diff --git a/tests/sys/mqueue/mqtest3.c b/tests/sys/mqueue/mqtest3.c
> index c4b849e..3e20c4d 100644
> --- a/tests/sys/mqueue/mqtest3.c
> +++ b/tests/sys/mqueue/mqtest3.c
> @@ -62,9 +62,10 @@ main(void)
>  		buf =3D malloc(attr.mq_msgsize);
>  		for (j =3D 0; j < LOOPS; ++j) {
>  			FD_ZERO(&set);
> -			FD_SET(__mq_oshandle(mq), &set);
> +			FD_SET(mq_getfd_np(mq), &set);
>  			alarm(3);
> -			status =3D select(__mq_oshandle(mq)+1, &set,
> NULL, NULL, NULL);
> +			status =3D select(mq_getfd_np(mq) + 1, &set,
> NULL,
> +			    NULL, NULL);
>  			if (status !=3D 1)
>  				err(1, "child process: select()");
>  			status =3D mq_receive(mq, buf,
> attr.mq_msgsize, &prio); @@ -94,8 +95,9 @@ main(void)
>  			}
>  			alarm(3);
>  			FD_ZERO(&set);
> -			FD_SET(__mq_oshandle(mq), &set);
> -			status =3D select(__mq_oshandle(mq)+1, NULL,
> &set, NULL, NULL);
> +			FD_SET(mq_getfd_np(mq), &set);
> +			status =3D select(mq_getfd_np(mq) + 1, NULL,
> &set,
> +			    NULL, NULL);
>  			if (status !=3D 1)
>  				err(1, "select()");
>  			status =3D mq_send(mq, buf, attr.mq_msgsize,
> PRIO); diff --git a/tests/sys/mqueue/mqtest4.c
> b/tests/sys/mqueue/mqtest4.c index 474d212..b0b3952 100644
> --- a/tests/sys/mqueue/mqtest4.c
> +++ b/tests/sys/mqueue/mqtest4.c
> @@ -57,7 +57,7 @@ main(void)
>  		mq =3D mq_open(MQNAME, O_RDWR);
>  		if (mq =3D=3D (mqd_t)-1)
>  			err(1, "child: mq_open");
> -		EV_SET(&kev, __mq_oshandle(mq), EVFILT_READ, EV_ADD,
> 0, 0, 0);
> +		EV_SET(&kev, mq_getfd_np(mq), EVFILT_READ, EV_ADD,
> 0, 0, 0); status =3D kevent(kq, &kev, 1, NULL, 0, NULL);
>  		if (status =3D=3D -1)
>  			err(1, "child: kevent");
> @@ -89,7 +89,7 @@ main(void)
> =20
>  		signal(SIGALRM, sighandler);
>  		kq =3D kqueue();
> -		EV_SET(&kev, __mq_oshandle(mq), EVFILT_WRITE,
> EV_ADD, 0, 0, 0);
> +		EV_SET(&kev, mq_getfd_np(mq), EVFILT_WRITE, EV_ADD,
> 0, 0, 0); status =3D kevent(kq, &kev, 1, NULL, 0, NULL);
>  		if (status =3D=3D -1)
>  			err(1, "kevent");

This looks good to me, thank you. If there is a desire to keep old
names exported, we can provide them as compat symbols too, so that old
binaries keep working. Software built from sources is better off
adapting new names which I think are quite a bit better.

--=20
Alexander Kabaev

--Sig_/Dx6k8femPnHps78YWcQVe8b
Content-Type: application/pgp-signature
Content-Description: Цифровая подпись OpenPGP

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQJ8BAEBCgBmBQJX8IHLXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w
ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXRDNUY3RDk5NTk5QjY0MUUxM0M1MTU2OTEw
NzEzMjI5OTkyNzkyRTdFAAoJEAcTIpmSeS5+53gQAJGhq4+dX6RCUdC60hKgzlbc
iZbBwwUK9PgKu2k8U9XMyheynpulo3rx0pK49dv96b7TlldetAOOO3Yc5Lh/gjMT
2dl2Jw4eyDlQx+PwpJvsUayH20BSuDsrKWZPkZ3kdDrKKJ8IenYVcdBUgcm9SrjM
PFPGaEJFPAwxC3C78hyiq38PA6T9G/ldlQkjTvD/GBMoKs09hozmUuXHfuWu3nbZ
JNy/OJWbPzWdmZ0rbEy0LthELTj5lCKVDscUzdqy4WO3iGIkkpKCNyq8gEgdLzG/
5As+CKun24rtGHBMyGMHp9VEF8GiBjDIlD03AnQK5OCpNy7zRtJ94C7EY/ukWmj1
3d9diX0Xlk31IlGoCi7/jKny+5reerhYMJiyxCGswwSKxm3dlrlSKKXpHI7sBOKR
KH651xmH0gYKBhH7EozNP0UC8/RpesHNl9iuUd4jmNHtu4ij83aYXtgWcTj1EU0z
UFs1jZQEgJpk2+y4OoKHEJVbQnCjxmOV3pc1cTSh7qFve8/r5Z2/CaYXVDRnNl4t
MaCBSzjGfEzurO7W8c8cYEy/LYjW8t9TaDcuw/hW/n8UTO+ZX3HHahP0pKxIJmGp
o6tJUnnpSsIBhDmLOvHoM4Pe8rmOjbOZ52FGqYhk1ztkPPyYUbYQal3VbDm2tDfY
5mIj2aG8AJCQMhrm7Zgd
=usTQ
-----END PGP SIGNATURE-----

--Sig_/Dx6k8femPnHps78YWcQVe8b--



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