Mercurial > hg > nginx
comparison src/event/ngx_event_udp.c @ 9107:adcc6d8acfd4 quic
Common tree insert function for QUIC and UDP connections.
Previously, ngx_udp_rbtree_insert_value() was used for plain UDP and
ngx_quic_rbtree_insert_value() was used for QUIC. Because of this it was
impossible to initialize connection tree in ngx_create_listening() since
this function is not aware what kind of listening it creates.
Now ngx_udp_rbtree_insert_value() is used for both QUIC and UDP. To make
is possible, a generic key field is added to ngx_udp_connection_t. It keeps
client address for UDP and connection ID for QUIC.
author | Roman Arutyunyan <arut@nginx.com> |
---|---|
date | Sun, 14 May 2023 12:30:11 +0400 |
parents | af5adec171b4 |
children |
comparison
equal
deleted
inserted
replaced
9106:113e2438dbd4 | 9107:adcc6d8acfd4 |
---|---|
415 c = udp->connection; | 415 c = udp->connection; |
416 | 416 |
417 udpt = (ngx_udp_connection_t *) temp; | 417 udpt = (ngx_udp_connection_t *) temp; |
418 ct = udpt->connection; | 418 ct = udpt->connection; |
419 | 419 |
420 rc = ngx_cmp_sockaddr(c->sockaddr, c->socklen, | 420 rc = ngx_memn2cmp(udp->key.data, udpt->key.data, |
421 ct->sockaddr, ct->socklen, 1); | 421 udp->key.len, udpt->key.len); |
422 | 422 |
423 if (rc == 0 && c->listening->wildcard) { | 423 if (rc == 0 && c->listening->wildcard) { |
424 rc = ngx_cmp_sockaddr(c->local_sockaddr, c->local_socklen, | 424 rc = ngx_cmp_sockaddr(c->local_sockaddr, c->local_socklen, |
425 ct->local_sockaddr, ct->local_socklen, 1); | 425 ct->local_sockaddr, ct->local_socklen, 1); |
426 } | 426 } |
469 } | 469 } |
470 | 470 |
471 ngx_crc32_final(hash); | 471 ngx_crc32_final(hash); |
472 | 472 |
473 udp->node.key = hash; | 473 udp->node.key = hash; |
474 udp->key.data = (u_char *) c->sockaddr; | |
475 udp->key.len = c->socklen; | |
474 | 476 |
475 cln = ngx_pool_cleanup_add(c->pool, 0); | 477 cln = ngx_pool_cleanup_add(c->pool, 0); |
476 if (cln == NULL) { | 478 if (cln == NULL) { |
477 return NGX_ERROR; | 479 return NGX_ERROR; |
478 } | 480 } |