@@ -3351,7 +3351,7 @@ lua tcp socket connect timeout: 100
33513351 location /t {
33523352 set $port $TEST_NGINX_SERVER_PORT;
33533353
3354- content_by_lua '
3354+ content_by_lua_block {
33553355 local sock = ngx.socket.tcp()
33563356 local port = ngx.var.port
33573357
@@ -3364,7 +3364,7 @@ lua tcp socket connect timeout: 100
33643364
33653365 ngx.say("connected: ", ok)
33663366
3367- local req = "GET /foo HTTP/1.0\\r\\ nHost: localhost\\r\\ nConnection: close\\r\\n\\r\ \n"
3367+ local req = "GET /foo HTTP/1.0\r\ nHost: localhost\r\ nConnection: close\r\n\r \n"
33683368
33693369 local bytes, err = sock:send(req)
33703370 if not bytes then
@@ -3385,7 +3385,7 @@ lua tcp socket connect timeout: 100
33853385 ok, err = sock:close()
33863386 ngx.say("close: ", ok, " ", err)
33873387 end
3388- ';
3388+ }
33893389 }
33903390
33913391 location /foo {
@@ -3416,7 +3416,7 @@ lua http cleanup reuse
34163416 #set $port 5000;
34173417 set $port $TEST_NGINX_SERVER_PORT;
34183418
3419- content_by_lua '
3419+ content_by_lua_block {
34203420 local total_send_bytes = 0
34213421 local port = ngx.var.port
34223422
@@ -3429,7 +3429,7 @@ lua http cleanup reuse
34293429 return
34303430 end
34313431
3432- local req = "GET /foo HTTP/1.0\\r\\ nHost: localhost\\r\\ nConnection: close\\r\\n\\r\ \n"
3432+ local req = "GET /foo HTTP/1.0\r\ nHost: localhost\r\ nConnection: close\r\n\r \n"
34333433
34343434 local bytes, err = sock:send(req)
34353435 if not bytes then
@@ -3449,22 +3449,33 @@ lua http cleanup reuse
34493449 ok, err = sock:close()
34503450 end
34513451
3452+ local done = false
3453+
34523454 local function double_network()
34533455 network()
34543456 network()
3457+ done = true
34553458 end
34563459
34573460 local ok, err = ngx.timer.at(0, double_network)
34583461 if not ok then
34593462 ngx.say("failed to create timer: ", err)
34603463 end
34613464
3462- ngx.sleep(0.2)
3465+ i = 1
3466+ while not done do
3467+ local time = 0.005 * i
3468+ if time > 0.1 then
3469+ time = 0.1
3470+ end
3471+ ngx.sleep(time)
3472+ i = i + 1
3473+ end
34633474
34643475 collectgarbage("collect")
34653476
34663477 ngx.say("total_send_bytes: ", total_send_bytes)
3467- ';
3478+ }
34683479 }
34693480
34703481 location /foo {
@@ -3481,14 +3492,14 @@ lua http cleanup reuse
34813492
34823493
34833494
3484- === TEST 58: free cleanup in ngx.timer(without sock:close)
3495+ === TEST 58: free cleanup in ngx.timer (without sock:close)
34853496--- config
34863497 server_tokens off;
34873498 location /t {
34883499 #set $port 5000;
34893500 set $port $TEST_NGINX_SERVER_PORT;
34903501
3491- content_by_lua '
3502+ content_by_lua_block {
34923503 local total_send_bytes = 0
34933504 local port = ngx.var.port
34943505
@@ -3501,7 +3512,7 @@ lua http cleanup reuse
35013512 return
35023513 end
35033514
3504- local req = "GET /foo HTTP/1.0\\r\\ nHost: localhost\\r\\ nConnection: close\\r\\n\\r\ \n"
3515+ local req = "GET /foo HTTP/1.0\r\ nHost: localhost\r\ nConnection: close\r\n\r \n"
35053516
35063517 local bytes, err = sock:send(req)
35073518 if not bytes then
@@ -3519,22 +3530,33 @@ lua http cleanup reuse
35193530 end
35203531 end
35213532
3533+ local done = false
3534+
35223535 local function double_network()
35233536 network()
35243537 network()
3538+ done = true
35253539 end
35263540
35273541 local ok, err = ngx.timer.at(0, double_network)
35283542 if not ok then
35293543 ngx.say("failed to create timer: ", err)
35303544 end
35313545
3532- ngx.sleep(0.2)
3546+ i = 1
3547+ while not done do
3548+ local time = 0.005 * i
3549+ if time > 0.1 then
3550+ time = 0.1
3551+ end
3552+ ngx.sleep(time)
3553+ i = i + 1
3554+ end
35333555
35343556 collectgarbage("collect")
35353557
35363558 ngx.say("total_send_bytes: ", total_send_bytes)
3537- ';
3559+ }
35383560 }
35393561
35403562 location /foo {
0 commit comments