aio/unix: Use signal.sival which is standard

Sepherosa Ziehau sepherosa at gmail.com
Thu Jan 24 02:07:57 UTC 2019


On Tue, Jan 22, 2019 at 10:54 PM Maxim Dounin <mdounin at mdounin.ru> wrote:
> This needs to be extended with some background information -
> notably why it used to be sigval_ptr, and why to switch to
> sival_ptr.

I am not sure why it used to be sigval_ptr; seems to be a miss name in
FreeBSD.  And the code seems to assume having KQUEUE == having
sigval_ptr.

As about why the switching:
- It's POSIX standard.
- It was noticed recently in DragonFly, since we removed this compat
field (sigval_ptr), since after scanning the source code in ports
system, nginx seems to be the only one using sigval_ptr.

Thanks,
sephe

>
> >
> > diff --git a/src/os/unix/ngx_file_aio_read.c b/src/os/unix/ngx_file_aio_read.c
> > --- a/src/os/unix/ngx_file_aio_read.c
> > +++ b/src/os/unix/ngx_file_aio_read.c
> > @@ -110,7 +110,7 @@ ngx_file_aio_read(ngx_file_t *file, u_ch
> >  #if (NGX_HAVE_KQUEUE)
> >      aio->aiocb.aio_sigevent.sigev_notify_kqueue = ngx_kqueue;
> >      aio->aiocb.aio_sigevent.sigev_notify = SIGEV_KEVENT;
> > -    aio->aiocb.aio_sigevent.sigev_value.sigval_ptr = ev;
> > +    aio->aiocb.aio_sigevent.sigev_value.sival_ptr = ev;
> >  #endif
> >      ev->handler = ngx_file_aio_event_handler;
> >
> > diff --git a/src/os/unix/ngx_freebsd_config.h b/src/os/unix/ngx_freebsd_config.h
> > --- a/src/os/unix/ngx_freebsd_config.h
> > +++ b/src/os/unix/ngx_freebsd_config.h
> > @@ -91,6 +91,10 @@
> >  #if (NGX_HAVE_FILE_AIO)
> >  #include <aio.h>
> >  typedef struct aiocb  ngx_aiocb_t;
> > +
> > +#if (__FreeBSD_version < 700005 && !defined __DragonFly__)
> > +#define sival_ptr                 sigval_ptr
> > +#endif
> >  #endif
> >
> >
>
> Minor style nits:
>
> diff --git a/src/os/unix/ngx_freebsd_config.h b/src/os/unix/ngx_freebsd_config.h
> --- a/src/os/unix/ngx_freebsd_config.h
> +++ b/src/os/unix/ngx_freebsd_config.h
> @@ -89,12 +89,14 @@
>
>
>  #if (NGX_HAVE_FILE_AIO)
> +
>  #include <aio.h>
>  typedef struct aiocb  ngx_aiocb_t;
>
>  #if (__FreeBSD_version < 700005 && !defined __DragonFly__)
> -#define sival_ptr                 sigval_ptr
> +#define sival_ptr     sigval_ptr
>  #endif
> +
>  #endif
>
>
> > # HG changeset patch
> > # User Sergey Kandaurov <pluknet at nginx.com>
> > # Date 1547736673 0
> > #      Thu Jan 17 14:51:13 2019 +0000
> > # Node ID c66911fc9924a60bb5d691ca00bc2fb1c3032866
> > # Parent  baab2b35e8cc79cfdf9924d1752348e97c1da13e
> > Removed --test-build-eventport workaround for old FreeBSD versions.
> >
> > diff --git a/src/event/modules/ngx_eventport_module.c b/src/event/modules/ngx_eventport_module.c
> > --- a/src/event/modules/ngx_eventport_module.c
> > +++ b/src/event/modules/ngx_eventport_module.c
> > @@ -250,9 +250,7 @@ ngx_eventport_init(ngx_cycle_t *cycle, n
> >
> >          ngx_memzero(&sev, sizeof(struct sigevent));
> >          sev.sigev_notify = SIGEV_PORT;
> > -#if !(NGX_TEST_BUILD_EVENTPORT)
> >          sev.sigev_value.sival_ptr = &pn;
> > -#endif
> >
> >          if (timer_create(CLOCK_REALTIME, &sev, &event_timer) == -1) {
> >              ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
>
> Looks fine.
>
> --
> Maxim Dounin
> http://mdounin.ru/
> _______________________________________________
> nginx-devel mailing list
> nginx-devel at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-devel



-- 
Tomorrow Will Never Die


More information about the nginx-devel mailing list