@@ -28,7 +28,7 @@ our $StapScript = $t::StapThread::StapScript;
28
28
29
29
repeat_each(2);
30
30
31
- plan tests => repeat_each() * 76 ;
31
+ plan tests => repeat_each() * 81 ;
32
32
33
33
# no_diff();
34
34
no_long_string();
@@ -439,3 +439,66 @@ failed to register a new timer after reload
439
439
--- grep_error_log_out
440
440
lua found 1 pending timers
441
441
442
+
443
+
444
+ === TEST 6: HUP reload should abort pending timers (fuzz test)
445
+ --- http_config
446
+ lua_max_pending_timers 8192;
447
+
448
+ --- config
449
+ location /t {
450
+ content_by_lua '
451
+ local job = function(premature, kill)
452
+ if premature then
453
+ return
454
+ end
455
+
456
+ if kill then
457
+ local f, err = io.open("t/servroot/logs/nginx.pid", "r")
458
+ if not f then
459
+ ngx.log(ngx.ERR, "failed to open nginx.pid: ", err)
460
+ return
461
+ end
462
+ local pid = f:read()
463
+ -- ngx.say("master pid: [", pid, "]")
464
+ f:close()
465
+
466
+ os.execute("kill -HUP " .. pid)
467
+ end
468
+ end
469
+
470
+ math.randomseed(ngx.time())
471
+ local rand = math.random
472
+ local newtimer = ngx.timer.at
473
+ for i = 1, 8191 do
474
+ local delay = rand(4096)
475
+ local ok, err = newtimer(delay, job, false)
476
+ if not ok then
477
+ ngx.say("failed to create timer at ", delay, ": ", err)
478
+ return
479
+ end
480
+ end
481
+ local ok, err = newtimer(0, job, true)
482
+ if not ok then
483
+ ngx.say("failed to create the killer timer: ", err)
484
+ return
485
+ end
486
+ ngx.say("ok")
487
+ ';
488
+ }
489
+ --- request
490
+ GET /t
491
+
492
+ --- response_body
493
+ ok
494
+
495
+ --- wait: 0.3
496
+ --- no_error_log
497
+ [error]
498
+ [alert]
499
+
500
+ --- grep_error_log eval: qr/lua found \d+ pending timers/
501
+ --- grep_error_log_out
502
+ lua found 8191 pending timers
503
+ --- timeout: 20
504
+
0 commit comments