mirror of
https://github.com/nginx/nginx.git
synced 2025-01-21 19:53:00 +08:00
QUIC: do not reallocate c->sockaddr.
When a connection is created, enough memory is allocated to accomodate any future address change.
This commit is contained in:
parent
496a434854
commit
daf9c643d1
@ -24,6 +24,7 @@ static ngx_connection_t *ngx_lookup_udp_connection(ngx_listening_t *ls,
|
||||
void
|
||||
ngx_event_recvmsg(ngx_event_t *ev)
|
||||
{
|
||||
size_t len;
|
||||
ssize_t n;
|
||||
ngx_str_t key;
|
||||
ngx_buf_t buf;
|
||||
@ -302,7 +303,15 @@ ngx_event_recvmsg(ngx_event_t *ev)
|
||||
return;
|
||||
}
|
||||
|
||||
c->sockaddr = ngx_palloc(c->pool, socklen);
|
||||
len = socklen;
|
||||
|
||||
#if (NGX_QUIC)
|
||||
if (ls->quic) {
|
||||
len = NGX_SOCKADDRLEN;
|
||||
}
|
||||
#endif
|
||||
|
||||
c->sockaddr = ngx_palloc(c->pool, len);
|
||||
if (c->sockaddr == NULL) {
|
||||
ngx_close_accepted_udp_connection(c);
|
||||
return;
|
||||
@ -704,13 +713,6 @@ ngx_lookup_udp_connection(ngx_listening_t *ls, ngx_str_t *key,
|
||||
}
|
||||
#endif
|
||||
|
||||
if (c->socklen < socklen) {
|
||||
c->sockaddr = ngx_palloc(c->pool, socklen);
|
||||
if (c->sockaddr == NULL) {
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
ngx_memcpy(c->sockaddr, sockaddr, socklen);
|
||||
c->socklen = socklen;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user