From 41a451e286cb6de9e0a0ad97f91a1dcac17ef68f Mon Sep 17 00:00:00 2001 From: Vladimir Homutov Date: Mon, 12 Nov 2018 16:29:30 +0300 Subject: Stream: proxy_requests directive. The directive allows to drop binding between a client and existing UDP stream session after receiving a specified number of packets. First packet from the same client address and port will start a new session. Old session continues to exist and will terminate at moment defined by configuration: either after receiving the expected number of responses, or after timeout, as specified by the "proxy_responses" and/or "proxy_timeout" directives. By default, proxy_requests is zero (disabled). --- src/event/ngx_event.h | 1 + src/event/ngx_event_udp.c | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'src/event') diff --git a/src/event/ngx_event.h b/src/event/ngx_event.h index c3979fb46..bb77c4ae6 100644 --- a/src/event/ngx_event.h +++ b/src/event/ngx_event.h @@ -509,6 +509,7 @@ void ngx_event_recvmsg(ngx_event_t *ev); void ngx_udp_rbtree_insert_value(ngx_rbtree_node_t *temp, ngx_rbtree_node_t *node, ngx_rbtree_node_t *sentinel); #endif +void ngx_delete_udp_connection(void *data); ngx_int_t ngx_trylock_accept_mutex(ngx_cycle_t *cycle); ngx_int_t ngx_enable_accept_events(ngx_cycle_t *cycle); u_char *ngx_accept_log_error(ngx_log_t *log, u_char *buf, size_t len); diff --git a/src/event/ngx_event_udp.c b/src/event/ngx_event_udp.c index 53b090475..65eb22fd2 100644 --- a/src/event/ngx_event_udp.c +++ b/src/event/ngx_event_udp.c @@ -23,7 +23,6 @@ static void ngx_close_accepted_udp_connection(ngx_connection_t *c); static ssize_t ngx_udp_shared_recv(ngx_connection_t *c, u_char *buf, size_t size); static ngx_int_t ngx_insert_udp_connection(ngx_connection_t *c); -static void ngx_delete_udp_connection(void *data); static ngx_connection_t *ngx_lookup_udp_connection(ngx_listening_t *ls, struct sockaddr *sockaddr, socklen_t socklen, struct sockaddr *local_sockaddr, socklen_t local_socklen); @@ -558,11 +557,15 @@ ngx_insert_udp_connection(ngx_connection_t *c) } -static void +void ngx_delete_udp_connection(void *data) { ngx_connection_t *c = data; + if (c->udp == NULL) { + return; + } + ngx_rbtree_delete(&c->listening->rbtree, &c->udp->node); c->udp = NULL; @@ -643,4 +646,12 @@ ngx_lookup_udp_connection(ngx_listening_t *ls, struct sockaddr *sockaddr, return NULL; } +#else + +void +ngx_delete_udp_connection(void *data) +{ + return; +} + #endif -- cgit