@@ -1020,6 +1020,14 @@ ngx_http_lua_run_thread(lua_State *L, ngx_http_request_t *r,
1020
1020
1021
1021
NGX_LUA_EXCEPTION_TRY {
1022
1022
1023
+ /*
1024
+ * silence a -Werror=clobbered warning with gcc 5.4
1025
+ * due to above setjmp
1026
+ */
1027
+ err = NULL ;
1028
+ msg = NULL ;
1029
+ trace = NULL ;
1030
+
1023
1031
if (ctx -> cur_co_ctx -> thread_spawn_yielded ) {
1024
1032
ngx_http_lua_probe_info ("thread spawn yielded" );
1025
1033
@@ -1389,29 +1397,33 @@ ngx_http_lua_run_thread(lua_State *L, ngx_http_request_t *r,
1389
1397
ctx -> cur_co_ctx = orig_coctx ;
1390
1398
}
1391
1399
1392
- if (lua_isstring (ctx -> cur_co_ctx -> co , -1 )) {
1393
- dd ("user custom error msg" );
1394
- msg = lua_tostring (ctx -> cur_co_ctx -> co , -1 );
1395
-
1396
- } else {
1397
- msg = "unknown reason" ;
1398
- }
1399
-
1400
1400
ngx_http_lua_cleanup_pending_operation (ctx -> cur_co_ctx );
1401
1401
1402
1402
ngx_http_lua_probe_coroutine_done (r , ctx -> cur_co_ctx -> co , 0 );
1403
1403
1404
1404
ctx -> cur_co_ctx -> co_status = NGX_HTTP_LUA_CO_DEAD ;
1405
1405
1406
- ngx_http_lua_thread_traceback (L , ctx -> cur_co_ctx -> co ,
1407
- ctx -> cur_co_ctx );
1408
- trace = lua_tostring (L , -1 );
1406
+ if (orig_coctx -> is_uthread
1407
+ || orig_coctx -> is_wrap
1408
+ || ngx_http_lua_is_entry_thread (ctx ))
1409
+ {
1410
+ ngx_http_lua_thread_traceback (L , orig_coctx -> co , orig_coctx );
1411
+ trace = lua_tostring (L , -1 );
1412
+
1413
+ if (lua_isstring (orig_coctx -> co , -1 )) {
1414
+ msg = lua_tostring (orig_coctx -> co , -1 );
1415
+ dd ("user custom error msg: %s" , msg );
1409
1416
1410
- propagate_error :
1417
+ } else {
1418
+ msg = "unknown reason" ;
1419
+ }
1420
+ }
1411
1421
1412
- ngx_http_lua_assert ( err != NULL && msg != NULL && trace != NULL );
1422
+ propagate_error :
1413
1423
1414
1424
if (ctx -> cur_co_ctx -> is_uthread ) {
1425
+ ngx_http_lua_assert (err != NULL && msg != NULL
1426
+ && trace != NULL );
1415
1427
1416
1428
ngx_log_error (NGX_LOG_ERR , r -> connection -> log , 0 ,
1417
1429
"lua user thread aborted: %s: %s\n%s" ,
@@ -1462,6 +1474,9 @@ ngx_http_lua_run_thread(lua_State *L, ngx_http_request_t *r,
1462
1474
}
1463
1475
1464
1476
if (ngx_http_lua_is_entry_thread (ctx )) {
1477
+ ngx_http_lua_assert (err != NULL && msg != NULL
1478
+ && trace != NULL );
1479
+
1465
1480
ngx_log_error (NGX_LOG_ERR , r -> connection -> log , 0 ,
1466
1481
"lua entry thread aborted: %s: %s\n%s" ,
1467
1482
err , msg , trace );
@@ -1519,9 +1534,6 @@ ngx_http_lua_run_thread(lua_State *L, ngx_http_request_t *r,
1519
1534
lua_xmove (orig_coctx -> co , next_co , 1 );
1520
1535
nrets = 2 ;
1521
1536
1522
- ngx_log_error (NGX_LOG_ERR , r -> connection -> log , 0 ,
1523
- "lua coroutine: %s: %s\n%s" , err , msg , trace );
1524
-
1525
1537
/* try resuming on the new coroutine again */
1526
1538
continue ;
1527
1539
}
0 commit comments