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:
Roman Arutyunyan 2021-03-11 15:22:18 +03:00
parent 496a434854
commit daf9c643d1

View File

@ -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;
}