@@ -468,8 +468,8 @@ ngx_http_lua_socket_resolve_handler(ngx_resolver_ctx_t *ctx)
468
468
lua_concat (L , 2 );
469
469
470
470
#if 1
471
- ur -> ctx = NULL ;
472
471
ngx_resolve_name_done (ctx );
472
+ ur -> ctx = NULL ;
473
473
#endif
474
474
475
475
u -> prepare_retvals = ngx_http_lua_socket_error_retval_handler ;
@@ -521,19 +521,7 @@ ngx_http_lua_socket_resolve_handler(ngx_resolver_ctx_t *ctx)
521
521
}
522
522
#endif
523
523
524
- if (ur -> naddrs == 0 ) {
525
- ngx_resolve_name_done (ctx );
526
- u -> ft_type |= NGX_HTTP_LUA_SOCKET_FT_RESOLVER ;
527
-
528
- lua_pushnil (L );
529
- lua_pushliteral (L , "name cannot be resolved to a address" );
530
-
531
- if (waiting ) {
532
- ngx_http_run_posted_requests (c );
533
- }
534
-
535
- return ;
536
- }
524
+ ngx_http_lua_assert (ur -> naddrs > 0 );
537
525
538
526
if (ur -> naddrs == 1 ) {
539
527
i = 0 ;
@@ -601,9 +589,8 @@ ngx_http_lua_socket_resolve_handler(ngx_resolver_ctx_t *ctx)
601
589
ur -> host .len = len ;
602
590
ur -> naddrs = 1 ;
603
591
604
- ur -> ctx = NULL ;
605
-
606
592
ngx_resolve_name_done (ctx );
593
+ ur -> ctx = NULL ;
607
594
608
595
u -> waiting = 0 ;
609
596
@@ -620,14 +607,21 @@ ngx_http_lua_socket_resolve_handler(ngx_resolver_ctx_t *ctx)
620
607
621
608
nomem :
622
609
623
- ngx_resolve_name_done (ctx );
624
- u -> ft_type |= NGX_HTTP_LUA_SOCKET_FT_NOMEM ;
610
+ if (ur -> ctx ) {
611
+ ngx_resolve_name_done (ctx );
612
+ ur -> ctx = NULL ;
613
+ }
625
614
626
- lua_pushnil (L );
627
- lua_pushliteral (L , "no memory" );
615
+ u -> prepare_retvals = ngx_http_lua_socket_error_retval_handler ;
616
+ ngx_http_lua_socket_udp_handle_error (r , u ,
617
+ NGX_HTTP_LUA_SOCKET_FT_NOMEM );
628
618
629
619
if (waiting ) {
630
620
ngx_http_run_posted_requests (c );
621
+
622
+ } else {
623
+ lua_pushnil (L );
624
+ lua_pushliteral (L , "no memory" );
631
625
}
632
626
}
633
627
@@ -1229,6 +1223,7 @@ ngx_http_lua_socket_udp_handle_error(ngx_http_request_t *r,
1229
1223
ngx_http_lua_socket_udp_upstream_t * u , ngx_uint_t ft_type )
1230
1224
{
1231
1225
ngx_http_lua_ctx_t * ctx ;
1226
+ ngx_http_lua_co_ctx_t * coctx ;
1232
1227
1233
1228
ngx_log_debug0 (NGX_LOG_DEBUG_HTTP , r -> connection -> log , 0 ,
1234
1229
"lua udp socket handle error" );
@@ -1241,8 +1236,10 @@ ngx_http_lua_socket_udp_handle_error(ngx_http_request_t *r,
1241
1236
1242
1237
u -> read_event_handler = ngx_http_lua_socket_dummy_handler ;
1243
1238
1244
- if (u -> co_ctx ) {
1245
- u -> co_ctx -> cleanup = NULL ;
1239
+ coctx = u -> co_ctx ;
1240
+
1241
+ if (coctx ) {
1242
+ coctx -> cleanup = NULL ;
1246
1243
}
1247
1244
1248
1245
if (u -> waiting ) {
@@ -1254,7 +1251,7 @@ ngx_http_lua_socket_udp_handle_error(ngx_http_request_t *r,
1254
1251
}
1255
1252
1256
1253
ctx -> resume_handler = ngx_http_lua_socket_udp_resume ;
1257
- ctx -> cur_co_ctx = u -> co_ctx ;
1254
+ ctx -> cur_co_ctx = coctx ;
1258
1255
1259
1256
ngx_log_debug0 (NGX_LOG_DEBUG_HTTP , r -> connection -> log , 0 ,
1260
1257
"lua udp socket waking up the current request" );
0 commit comments