annotate src/core/ngx_crc.h @ 7892:2096b21fcd10

gRPC: RST_STREAM(NO_ERROR) handling (ticket #1792). As per https://tools.ietf.org/html/rfc7540#section-8.1, : A server can send a complete response prior to the client : sending an entire request if the response does not depend on : any portion of the request that has not been sent and : received. When this is true, a server MAY request that the : client abort transmission of a request without error by : sending a RST_STREAM with an error code of NO_ERROR after : sending a complete response (i.e., a frame with the : END_STREAM flag). Clients MUST NOT discard responses as a : result of receiving such a RST_STREAM, though clients can : always discard responses at their discretion for other : reasons. Previously, RST_STREAM(NO_ERROR) received from upstream after a frame with the END_STREAM flag was incorrectly treated as an error. Now, a single RST_STREAM(NO_ERROR) is properly handled. This fixes problems observed with modern grpc-c [1], as well as with the Go gRPC module. [1] https://github.com/grpc/grpc/pull/1661
author Ruslan Ermilov <ru@nginx.com>
date Thu, 23 Apr 2020 15:10:24 +0300
parents d620f497c50f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
441
da8c5707af39 nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents: 208
diff changeset
1
da8c5707af39 nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents: 208
diff changeset
2 /*
444
42d11f017717 nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents: 441
diff changeset
3 * Copyright (C) Igor Sysoev
4412
d620f497c50f Copyright updated.
Maxim Konovalov <maxim@nginx.com>
parents: 792
diff changeset
4 * Copyright (C) Nginx, Inc.
441
da8c5707af39 nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents: 208
diff changeset
5 */
da8c5707af39 nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents: 208
diff changeset
6
da8c5707af39 nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents: 208
diff changeset
7
201
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
8 #ifndef _NGX_CRC_H_INCLUDED_
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
9 #define _NGX_CRC_H_INCLUDED_
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
10
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
11
792
99858705b03f add includes
Igor Sysoev <igor@sysoev.ru>
parents: 789
diff changeset
12 #include <ngx_config.h>
99858705b03f add includes
Igor Sysoev <igor@sysoev.ru>
parents: 789
diff changeset
13 #include <ngx_core.h>
99858705b03f add includes
Igor Sysoev <igor@sysoev.ru>
parents: 789
diff changeset
14
99858705b03f add includes
Igor Sysoev <igor@sysoev.ru>
parents: 789
diff changeset
15
201
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
16 /* 32-bit crc16 */
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
17
776
5622cdd48e5b style fix
Igor Sysoev <igor@sysoev.ru>
parents: 467
diff changeset
18 static ngx_inline uint32_t
789
604f9671fae6 char* > u_char*
Igor Sysoev <igor@sysoev.ru>
parents: 776
diff changeset
19 ngx_crc(u_char *data, size_t len)
201
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
20 {
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
21 uint32_t sum;
208
0b67be7d4489 nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 201
diff changeset
22
201
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
23 for (sum = 0; len; len--) {
441
da8c5707af39 nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents: 208
diff changeset
24
201
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
25 /*
776
5622cdd48e5b style fix
Igor Sysoev <igor@sysoev.ru>
parents: 467
diff changeset
26 * gcc 2.95.2 x86 and icc 7.1.006 compile
5622cdd48e5b style fix
Igor Sysoev <igor@sysoev.ru>
parents: 467
diff changeset
27 * that operator into the single "rol" opcode,
201
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
28 * msvc 6.0sp2 compiles it into four opcodes.
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
29 */
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
30 sum = sum >> 1 | sum << 31;
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
31
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
32 sum += *data++;
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
33 }
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
34
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
35 return sum;
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
36 }
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
37
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
38
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
39 #endif /* _NGX_CRC_H_INCLUDED_ */