Mercurial > hg > nginx
annotate src/event/ngx_event_udp.h @ 9295:c5623963c29e
Upstream: fixed proxy_no_cache when caching errors.
Caching errors, notably intercepted errors and internally generated
502/504 errors, as well as handling of cache revalidation with 304,
did not take into account u->conf->no_cache predicates configured.
As a result, an error might be cached even if configuration explicitly
says not to. Fix is to check u->conf->no_cache in these cases.
To simplify usage in multiple places, checking u->conf->no_cache is now
done in a separate function. As a minor optimization, u->conf->no_cache
is only checked if u->cacheable is set.
As a side effect, this change also fixes caching errors after
proxy_cache_bypass. Also, during cache revalidation u->cacheable is
now tested, so 304 responses which disable caching won't extend
cacheability of stored responses.
Additionally, when caching internally generated 502/504 errors
u->cacheable is now explicitly updated from u->headers_in.no_cache and
u->headers_in.expired, restoring the behaviour before 8041:0784ab86ad08
(1.23.0) when an error happens while reading the response headers.
Reported by Kirill A. Korinsky,
https://freenginx.org/pipermail/nginx/2024-April/000082.html
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Tue, 25 Jun 2024 21:44:50 +0300 |
parents | adcc6d8acfd4 |
children |
rev | line source |
---|---|
8001
8206ecdcd837
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1 |
8206ecdcd837
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
2 /* |
8206ecdcd837
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
3 * Copyright (C) Nginx, Inc. |
8206ecdcd837
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
4 */ |
8206ecdcd837
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
5 |
8206ecdcd837
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
6 |
8206ecdcd837
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
7 #ifndef _NGX_EVENT_UDP_H_INCLUDED_ |
8206ecdcd837
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
8 #define _NGX_EVENT_UDP_H_INCLUDED_ |
8206ecdcd837
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
9 |
8206ecdcd837
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
10 |
8206ecdcd837
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
11 #include <ngx_config.h> |
8206ecdcd837
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
12 #include <ngx_core.h> |
8206ecdcd837
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
13 |
8206ecdcd837
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
14 |
8206ecdcd837
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
15 #if !(NGX_WIN32) |
8002
cfe1284e5d1d
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8001
diff
changeset
|
16 |
cfe1284e5d1d
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8001
diff
changeset
|
17 #if ((NGX_HAVE_MSGHDR_MSG_CONTROL) \ |
cfe1284e5d1d
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8001
diff
changeset
|
18 && (NGX_HAVE_IP_SENDSRCADDR || NGX_HAVE_IP_RECVDSTADDR \ |
cfe1284e5d1d
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8001
diff
changeset
|
19 || NGX_HAVE_IP_PKTINFO \ |
cfe1284e5d1d
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8001
diff
changeset
|
20 || (NGX_HAVE_INET6 && NGX_HAVE_IPV6_RECVPKTINFO))) |
cfe1284e5d1d
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8001
diff
changeset
|
21 #define NGX_HAVE_ADDRINFO_CMSG 1 |
cfe1284e5d1d
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8001
diff
changeset
|
22 |
cfe1284e5d1d
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8001
diff
changeset
|
23 #endif |
cfe1284e5d1d
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8001
diff
changeset
|
24 |
cfe1284e5d1d
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8001
diff
changeset
|
25 |
8809
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
26 struct ngx_udp_connection_s { |
9017
c2f5d79cde64
QUIC: separate UDP framework for QUIC.
Roman Arutyunyan <arut@nginx.com>
parents:
9008
diff
changeset
|
27 ngx_rbtree_node_t node; |
c2f5d79cde64
QUIC: separate UDP framework for QUIC.
Roman Arutyunyan <arut@nginx.com>
parents:
9008
diff
changeset
|
28 ngx_connection_t *connection; |
c2f5d79cde64
QUIC: separate UDP framework for QUIC.
Roman Arutyunyan <arut@nginx.com>
parents:
9008
diff
changeset
|
29 ngx_buf_t *buffer; |
9107
adcc6d8acfd4
Common tree insert function for QUIC and UDP connections.
Roman Arutyunyan <arut@nginx.com>
parents:
9017
diff
changeset
|
30 ngx_str_t key; |
8809
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
31 }; |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
32 |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
33 |
8002
cfe1284e5d1d
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8001
diff
changeset
|
34 #if (NGX_HAVE_ADDRINFO_CMSG) |
cfe1284e5d1d
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8001
diff
changeset
|
35 |
cfe1284e5d1d
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8001
diff
changeset
|
36 typedef union { |
cfe1284e5d1d
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8001
diff
changeset
|
37 #if (NGX_HAVE_IP_SENDSRCADDR || NGX_HAVE_IP_RECVDSTADDR) |
cfe1284e5d1d
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8001
diff
changeset
|
38 struct in_addr addr; |
cfe1284e5d1d
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8001
diff
changeset
|
39 #endif |
cfe1284e5d1d
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8001
diff
changeset
|
40 |
cfe1284e5d1d
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8001
diff
changeset
|
41 #if (NGX_HAVE_IP_PKTINFO) |
cfe1284e5d1d
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8001
diff
changeset
|
42 struct in_pktinfo pkt; |
cfe1284e5d1d
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8001
diff
changeset
|
43 #endif |
cfe1284e5d1d
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8001
diff
changeset
|
44 |
cfe1284e5d1d
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8001
diff
changeset
|
45 #if (NGX_HAVE_INET6 && NGX_HAVE_IPV6_RECVPKTINFO) |
cfe1284e5d1d
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8001
diff
changeset
|
46 struct in6_pktinfo pkt6; |
cfe1284e5d1d
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8001
diff
changeset
|
47 #endif |
cfe1284e5d1d
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8001
diff
changeset
|
48 } ngx_addrinfo_t; |
cfe1284e5d1d
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8001
diff
changeset
|
49 |
cfe1284e5d1d
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8001
diff
changeset
|
50 size_t ngx_set_srcaddr_cmsg(struct cmsghdr *cmsg, |
cfe1284e5d1d
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8001
diff
changeset
|
51 struct sockaddr *local_sockaddr); |
8003
0f6cc8f73744
Core: added function for local source address cmsg.
Vladimir Homutov <vl@nginx.com>
parents:
8002
diff
changeset
|
52 ngx_int_t ngx_get_srcaddr_cmsg(struct cmsghdr *cmsg, |
0f6cc8f73744
Core: added function for local source address cmsg.
Vladimir Homutov <vl@nginx.com>
parents:
8002
diff
changeset
|
53 struct sockaddr *local_sockaddr); |
8002
cfe1284e5d1d
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8001
diff
changeset
|
54 |
cfe1284e5d1d
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8001
diff
changeset
|
55 #endif |
cfe1284e5d1d
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8001
diff
changeset
|
56 |
8001
8206ecdcd837
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
57 void ngx_event_recvmsg(ngx_event_t *ev); |
8002
cfe1284e5d1d
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8001
diff
changeset
|
58 ssize_t ngx_sendmsg(ngx_connection_t *c, struct msghdr *msg, int flags); |
8001
8206ecdcd837
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
59 void ngx_udp_rbtree_insert_value(ngx_rbtree_node_t *temp, |
8206ecdcd837
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
60 ngx_rbtree_node_t *node, ngx_rbtree_node_t *sentinel); |
8206ecdcd837
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
61 #endif |
8206ecdcd837
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
62 |
8206ecdcd837
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
63 void ngx_delete_udp_connection(void *data); |
8206ecdcd837
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
64 |
8206ecdcd837
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
65 |
8206ecdcd837
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
66 #endif /* _NGX_EVENT_UDP_H_INCLUDED_ */ |