Mercurial > hg > nginx
annotate src/os/unix/ngx_sunpro_x86.il @ 7583:efd71d49bde0
Events: available bytes calculation via ioctl(FIONREAD).
This makes it possible to avoid looping for a long time while working
with a fast enough peer when data are added to the socket buffer faster
than we are able to read and process them (ticket #1431). This is
basically what we already do on FreeBSD with kqueue, where information
about the number of bytes in the socket buffer is returned by
the kevent() call.
With other event methods rev->available is now set to -1 when the socket
is ready for reading. Later in ngx_recv() and ngx_recv_chain(), if
full buffer is received, real number of bytes in the socket buffer is
retrieved using ioctl(FIONREAD). Reading more than this number of bytes
ensures that even with edge-triggered event methods the event will be
triggered again, so it is safe to stop processing of the socket and
switch to other connections.
Using ioctl(FIONREAD) only after reading a full buffer is an optimization.
With this approach we only call ioctl(FIONREAD) when there are at least
two recv()/readv() calls.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 17 Oct 2019 16:02:19 +0300 |
parents | 2cd019520210 |
children |
rev | line source |
---|---|
561 | 1 / |
2 / Copyright (C) Igor Sysoev | |
4412 | 3 / Copyright (C) Nginx, Inc. |
561 | 4 / |
5 | |
6 / ngx_atomic_uint_t ngx_atomic_cmp_set(ngx_atomic_t *lock, | |
7 / ngx_atomic_uint_t old, ngx_atomic_uint_t set); | |
8 / | |
2818
7e02df612521
preserve Solaris binary hardware capabilities
Igor Sysoev <igor@sysoev.ru>
parents:
1309
diff
changeset
|
9 / the arguments are passed on stack (%esp), 4(%esp), 8(%esp) |
561 | 10 |
11 .inline ngx_atomic_cmp_set,0 | |
12 movl (%esp), %ecx | |
13 movl 4(%esp), %eax | |
14 movl 8(%esp), %edx | |
15 lock | |
16 cmpxchgl %edx, (%ecx) | |
17 setz %al | |
18 movzbl %al, %eax | |
19 .end | |
20 | |
21 | |
22 / ngx_atomic_int_t ngx_atomic_fetch_add(ngx_atomic_t *value, | |
23 / ngx_atomic_int_t add); | |
24 / | |
2818
7e02df612521
preserve Solaris binary hardware capabilities
Igor Sysoev <igor@sysoev.ru>
parents:
1309
diff
changeset
|
25 / the arguments are passed on stack (%esp), 4(%esp) |
561 | 26 |
27 .inline ngx_atomic_fetch_add,0 | |
28 movl (%esp), %ecx | |
29 movl 4(%esp), %eax | |
30 lock | |
31 xaddl %eax, (%ecx) | |
32 .end | |
1309 | 33 |
34 | |
35 / ngx_cpu_pause() | |
2818
7e02df612521
preserve Solaris binary hardware capabilities
Igor Sysoev <igor@sysoev.ru>
parents:
1309
diff
changeset
|
36 / |
7e02df612521
preserve Solaris binary hardware capabilities
Igor Sysoev <igor@sysoev.ru>
parents:
1309
diff
changeset
|
37 / the "rep; nop" is used instead of "pause" to avoid the "[ PAUSE ]" hardware |
7e02df612521
preserve Solaris binary hardware capabilities
Igor Sysoev <igor@sysoev.ru>
parents:
1309
diff
changeset
|
38 / capability added by linker because Solaris/i386 does not know about it: |
7e02df612521
preserve Solaris binary hardware capabilities
Igor Sysoev <igor@sysoev.ru>
parents:
1309
diff
changeset
|
39 / |
7e02df612521
preserve Solaris binary hardware capabilities
Igor Sysoev <igor@sysoev.ru>
parents:
1309
diff
changeset
|
40 / ld.so.1: nginx: fatal: hardware capability unsupported: 0x2000 [ PAUSE ] |
1309 | 41 |
6474 | 42 .inline ngx_cpu_pause,0 |
43 rep; nop | |
44 .end |