[PATCH] ngx_thread_id openbsd specific
Maxim Dounin
mdounin at mdounin.ru
Sun Jul 22 00:59:18 UTC 2018
Hello!
On Sat, Jul 21, 2018 at 09:26:47PM +0100, David CARLIER wrote:
> Here a patch proposal to use specific getthrid function instead of the
> generic pthread_self.
You may be more specific about reasons to use getthrid() instead
of pthread_self().
Also, it looks like OpenBSD does not have EVFILT_USER, so
compiling nginx with threads support is meaningless anyway.
See also http://nginx.org/en/docs/contributing_changes.html for
some hints on how to submit patches.
> diff -r 6649d4433266 auto/os/conf
> --- a/auto/os/conf Wed Jul 18 18:51:25 2018 +0300
> +++ b/auto/os/conf Sat Jul 21 21:24:26 2018 +0100
> @@ -27,6 +27,15 @@
> . auto/os/win32
> ;;
>
> + OpenBSD:*)
> + have=NGX_OPENBSD . auto/have_headers
> + CORE_INCS="$UNIX_INCS"
> + CORE_DEPS="$UNIX_DEPS $POSIX_DEPS"
> + CORE_SRCS="$UNIX_SRCS"
> +
> + NGX_RPATH=YES
This instructs nginx to use rpath on OpenBSD. Are there any
reasons to do this? Normally we do not use rpath unless the OS
cannot load libraries from their standard locations itself, and it
looks like OpenBSD can do this just fine.
> + ;;
> +
> DragonFly:*)
> have=NGX_FREEBSD . auto/have_headers
> CORE_INCS="$UNIX_INCS"
> diff -r 6649d4433266 src/os/unix/ngx_thread.h
> --- a/src/os/unix/ngx_thread.h Wed Jul 18 18:51:25 2018 +0300
> +++ b/src/os/unix/ngx_thread.h Sat Jul 21 21:24:26 2018 +0100
> @@ -44,6 +44,11 @@
> typedef uint32_t ngx_tid_t;
> #define NGX_TID_T_FMT "%uD"
>
> +#elif (NGX_OPENBSD)
> +
> +typedef int64_t ngx_tid_t;
This defines ngx_tid_t to int64_t, while getthrid() is expected to
return pid_t, see https://man.openbsd.org/getthrid.2. Are there
any specific reasons to use int64_t instead of pid_t?
> +#define NGX_TID_T_FMT "%lD"
This format specification means that nginx will us a signed long
argument, followed by the "D" character. Unlikely this is what
you mean here. For pid_t, the "%P" format should be used.
(BTW, thanks, the format specification for uint64_t as used now
looks wrong too, it should be "%uL" instead of "%uA". I'll take
care of this.)
> +
> #elif (NGX_DARWIN)
>
> typedef uint64_t ngx_tid_t;
> diff -r 6649d4433266 src/os/unix/ngx_thread_id.c
> --- a/src/os/unix/ngx_thread_id.c Wed Jul 18 18:51:25 2018 +0300
> +++ b/src/os/unix/ngx_thread_id.c Sat Jul 21 21:24:26 2018 +0100
> @@ -33,6 +33,14 @@
> return pthread_getthreadid_np();
> }
>
> +#elif (NGX_OPENBSD)
> +
> +ngx_tid_t
> +ngx_thread_tid(void)
> +{
> + return getthrid();
> +}
> +
> #elif (NGX_DARWIN)
>
> /*
--
Maxim Dounin
http://mdounin.ru/
More information about the nginx-devel
mailing list