@@ -54,7 +54,7 @@ static void ngx_http_lua_socket_udp_read_handler(ngx_http_request_t *r,
5454 ngx_http_lua_socket_udp_upstream_t * u );
5555static void ngx_http_lua_socket_udp_handle_success (ngx_http_request_t * r ,
5656 ngx_http_lua_socket_udp_upstream_t * u );
57- static ngx_int_t ngx_http_lua_udp_connect (ngx_udp_connection_t * uc );
57+ static ngx_int_t ngx_http_lua_udp_connect (ngx_resolver_connection_t * uc );
5858static int ngx_http_lua_socket_udp_close (lua_State * L );
5959static ngx_int_t ngx_http_lua_socket_udp_resume (ngx_http_request_t * r );
6060static void ngx_http_lua_udp_resolve_cleanup (void * data );
@@ -170,7 +170,7 @@ ngx_http_lua_socket_udp_setpeername(lua_State *L)
170170 ngx_url_t url ;
171171 ngx_int_t rc ;
172172 ngx_http_lua_loc_conf_t * llcf ;
173- ngx_udp_connection_t * uc ;
173+ ngx_resolver_connection_t * uc ;
174174 int timeout ;
175175 ngx_http_lua_co_ctx_t * coctx ;
176176
@@ -246,7 +246,7 @@ ngx_http_lua_socket_udp_setpeername(lua_State *L)
246246 return 2 ;
247247 }
248248
249- if (u -> udp_connection .connection ) {
249+ if (u -> udp_connection .udp ) {
250250 ngx_log_debug0 (NGX_LOG_DEBUG_HTTP , r -> connection -> log , 0 ,
251251 "lua udp socket reconnect without shutting down" );
252252
@@ -642,7 +642,7 @@ ngx_http_lua_socket_resolve_retval_handler(ngx_http_request_t *r,
642642{
643643 ngx_http_lua_ctx_t * ctx ;
644644 ngx_http_lua_co_ctx_t * coctx ;
645- ngx_udp_connection_t * uc ;
645+ ngx_resolver_connection_t * uc ;
646646 ngx_connection_t * c ;
647647 ngx_http_cleanup_t * cln ;
648648 ngx_http_upstream_resolved_t * ur ;
@@ -699,7 +699,7 @@ ngx_http_lua_socket_resolve_retval_handler(ngx_http_request_t *r,
699699
700700 /* rc == NGX_OK */
701701
702- c = uc -> connection ;
702+ c = uc -> udp ;
703703
704704 c -> data = u ;
705705
@@ -806,13 +806,13 @@ ngx_http_lua_socket_udp_send(lua_State *L)
806806 u = lua_touserdata (L , -1 );
807807 lua_pop (L , 1 );
808808
809- if (u == NULL || u -> udp_connection .connection == NULL ) {
809+ if (u == NULL || u -> udp_connection .udp == NULL ) {
810810 llcf = ngx_http_get_module_loc_conf (r , ngx_http_lua_module );
811811
812812 if (llcf -> log_socket_errors ) {
813813 ngx_log_error (NGX_LOG_ERR , r -> connection -> log , 0 ,
814814 "attempt to send data on a closed socket: u:%p, c:%p" ,
815- u , u ? u -> udp_connection .connection : NULL );
815+ u , u ? u -> udp_connection .udp : NULL );
816816 }
817817
818818 lua_pushnil (L );
@@ -881,7 +881,7 @@ ngx_http_lua_socket_udp_send(lua_State *L)
881881
882882 dd ("sending query %.*s" , (int ) query .len , query .data );
883883
884- n = ngx_send (u -> udp_connection .connection , query .data , query .len );
884+ n = ngx_send (u -> udp_connection .udp , query .data , query .len );
885885
886886 dd ("ngx_send returns %d (query len %d)" , (int ) n , (int ) query .len );
887887
@@ -937,13 +937,13 @@ ngx_http_lua_socket_udp_receive(lua_State *L)
937937 u = lua_touserdata (L , -1 );
938938 lua_pop (L , 1 );
939939
940- if (u == NULL || u -> udp_connection .connection == NULL ) {
940+ if (u == NULL || u -> udp_connection .udp == NULL ) {
941941 llcf = ngx_http_get_module_loc_conf (r , ngx_http_lua_module );
942942
943943 if (llcf -> log_socket_errors ) {
944944 ngx_log_error (NGX_LOG_ERR , r -> connection -> log , 0 ,
945945 "attempt to receive data on a closed socket: u:%p, "
946- "c:%p" , u , u ? u -> udp_connection .connection : NULL );
946+ "c:%p" , u , u ? u -> udp_connection .udp : NULL );
947947 }
948948
949949 lua_pushnil (L );
@@ -1094,12 +1094,12 @@ ngx_http_lua_socket_udp_finalize(ngx_http_request_t *r,
10941094 u -> resolved -> ctx = NULL ;
10951095 }
10961096
1097- if (u -> udp_connection .connection ) {
1097+ if (u -> udp_connection .udp ) {
10981098 ngx_log_debug0 (NGX_LOG_DEBUG_HTTP , r -> connection -> log , 0 ,
10991099 "lua close socket connection" );
11001100
1101- ngx_close_connection (u -> udp_connection .connection );
1102- u -> udp_connection .connection = NULL ;
1101+ ngx_close_connection (u -> udp_connection .udp );
1102+ u -> udp_connection .udp = NULL ;
11031103 }
11041104
11051105 if (u -> waiting ) {
@@ -1145,13 +1145,13 @@ ngx_http_lua_socket_udp_read(ngx_http_request_t *r,
11451145 ngx_event_t * rev ;
11461146 ssize_t n ;
11471147
1148- c = u -> udp_connection .connection ;
1148+ c = u -> udp_connection .udp ;
11491149 rev = c -> read ;
11501150
11511151 ngx_log_debug1 (NGX_LOG_DEBUG_HTTP , c -> log , 0 ,
11521152 "lua udp socket read data: waiting: %d" , (int ) u -> waiting );
11531153
1154- n = ngx_udp_recv (u -> udp_connection .connection ,
1154+ n = ngx_udp_recv (u -> udp_connection .udp ,
11551155 ngx_http_lua_socket_udp_buffer , u -> recv_buf_size );
11561156
11571157 ngx_log_debug1 (NGX_LOG_DEBUG_HTTP , c -> log , 0 ,
@@ -1198,7 +1198,7 @@ ngx_http_lua_socket_udp_read_handler(ngx_http_request_t *r,
11981198 ngx_connection_t * c ;
11991199 ngx_http_lua_loc_conf_t * llcf ;
12001200
1201- c = u -> udp_connection .connection ;
1201+ c = u -> udp_connection .udp ;
12021202
12031203 ngx_log_debug0 (NGX_LOG_DEBUG_HTTP , r -> connection -> log , 0 ,
12041204 "lua udp socket read handler" );
@@ -1348,7 +1348,7 @@ ngx_http_lua_socket_udp_handle_success(ngx_http_request_t *r,
13481348
13491349
13501350static ngx_int_t
1351- ngx_http_lua_udp_connect (ngx_udp_connection_t * uc )
1351+ ngx_http_lua_udp_connect (ngx_resolver_connection_t * uc )
13521352{
13531353 int rc ;
13541354 ngx_int_t event ;
@@ -1398,7 +1398,7 @@ ngx_http_lua_udp_connect(ngx_udp_connection_t *uc)
13981398 rev -> log = & uc -> log ;
13991399 wev -> log = & uc -> log ;
14001400
1401- uc -> connection = c ;
1401+ uc -> udp = c ;
14021402
14031403 c -> number = ngx_atomic_fetch_add (ngx_connection_counter , 1 );
14041404
@@ -1414,7 +1414,7 @@ ngx_http_lua_udp_connect(ngx_udp_connection_t *uc)
14141414 ngx_log_debug0 (NGX_LOG_DEBUG_EVENT , & uc -> log , 0 , "datagram unix "
14151415 "domain socket autobind" );
14161416
1417- if (bind (uc -> connection -> fd , & addr , sizeof (sa_family_t )) != 0 ) {
1417+ if (bind (uc -> udp -> fd , & addr , sizeof (sa_family_t )) != 0 ) {
14181418 ngx_log_error (NGX_LOG_CRIT , & uc -> log , ngx_socket_errno ,
14191419 "bind() failed" );
14201420
@@ -1485,7 +1485,7 @@ ngx_http_lua_socket_udp_close(lua_State *L)
14851485 u = lua_touserdata (L , -1 );
14861486 lua_pop (L , 1 );
14871487
1488- if (u == NULL || u -> udp_connection .connection == NULL ) {
1488+ if (u == NULL || u -> udp_connection .udp == NULL ) {
14891489 lua_pushnil (L );
14901490 lua_pushliteral (L , "closed" );
14911491 return 2 ;
0 commit comments