view src/os/unix/ngx_sunpro_amd64.il @ 8058:f3510cb959d1

Events: fixed EPOLLRDHUP with FIONREAD (ticket #2367). When reading exactly rev->available bytes, rev->available might become 0 after FIONREAD usage introduction in efd71d49bde0. On the next call of ngx_readv_chain() on systems with EPOLLRDHUP this resulted in return without any actions, that is, with rev->ready set, and this in turn resulted in no timers set in event pipe, leading to socket leaks. Fix is to reset rev->ready in ngx_readv_chain() when returning due to rev->available being 0 with EPOLLRDHUP, much like it is already done in ngx_unix_recv(). This ensures that if rev->available will become 0, on systems with EPOLLRDHUP support appropriate EPOLLRDHUP-specific handling will happen on the next ngx_readv_chain() call. While here, also synced ngx_readv_chain() to match ngx_unix_recv() and reset rev->ready when returning due to rev->available being 0 with kqueue. This is mostly cosmetic change, as rev->ready is anyway reset when rev->available is set to 0.
author Maxim Dounin <mdounin@mdounin.ru>
date Fri, 15 Jul 2022 15:19:32 +0300
parents 2cd019520210
children
line wrap: on
line source

/
/ Copyright (C) Igor Sysoev
/ Copyright (C) Nginx, Inc.
/

/ ngx_atomic_uint_t ngx_atomic_cmp_set(ngx_atomic_t *lock,
/     ngx_atomic_uint_t old, ngx_atomic_uint_t set);
/
/ the arguments are passed in %rdi, %rsi, %rdx
/ the result is returned in the %rax

        .inline ngx_atomic_cmp_set,0
        movq      %rsi, %rax
        lock
        cmpxchgq  %rdx, (%rdi)
        setz      %al
        movzbq    %al, %rax
        .end


/ ngx_atomic_int_t ngx_atomic_fetch_add(ngx_atomic_t *value,
/     ngx_atomic_int_t add);
/
/ the arguments are passed in %rdi, %rsi
/ the result is returned in the %rax

        .inline ngx_atomic_fetch_add,0
        movq      %rsi, %rax
        lock
        xaddq     %rax, (%rdi)
        .end


/ ngx_cpu_pause()
/
/ the "rep; nop" is used instead of "pause" to avoid the "[ PAUSE ]" hardware
/ capability added by linker because Solaris/amd64 does not know about it:
/
/ ld.so.1: nginx: fatal: hardware capability unsupported: 0x2000 [ PAUSE ]

        .inline ngx_cpu_pause,0
        rep; nop
        .end