@@ -4,7 +4,7 @@ use Test::Nginx::Socket::Lua;
4
4
5
5
repeat_each(2);
6
6
7
- plan tests => repeat_each() * 219 ;
7
+ plan tests => repeat_each() * 222 ;
8
8
9
9
our $HtmlDir = html_dir;
10
10
@@ -3643,7 +3643,45 @@ lua http cleanup reuse
3643
3643
3644
3644
3645
3645
3646
- === TEST 60: options_table is nil
3646
+ === TEST 60: setkeepalive on socket already shutdown
3647
+ --- config
3648
+ location /t {
3649
+ set $port $TEST_NGINX_MEMCACHED_PORT;
3650
+
3651
+ content_by_lua_block {
3652
+ local sock = ngx.socket.tcp()
3653
+ local port = ngx.var.port
3654
+
3655
+ local ok, err = sock:connect("127.0.0.1", port)
3656
+ if not ok then
3657
+ ngx.say("failed to connect: ", err)
3658
+ return
3659
+ end
3660
+
3661
+ ngx.say("connected: ", ok)
3662
+
3663
+ local ok, err = sock:close()
3664
+ if not ok then
3665
+ ngx.log(ngx.ERR, "failed to close socket: ", err)
3666
+ return
3667
+ end
3668
+
3669
+ local ok, err = sock:setkeepalive()
3670
+ if not ok then
3671
+ ngx.log(ngx.ERR, "failed to setkeepalive: ", err)
3672
+ end
3673
+ }
3674
+ }
3675
+ --- request
3676
+ GET /t
3677
+ --- response_body
3678
+ connected: 1
3679
+ --- error_log
3680
+ failed to setkeepalive: closed
3681
+
3682
+
3683
+
3684
+ === TEST 61: options_table is nil
3647
3685
--- config
3648
3686
location /t {
3649
3687
set $port $TEST_NGINX_MEMCACHED_PORT;
@@ -3693,7 +3731,7 @@ close: 1 nil
3693
3731
3694
3732
3695
3733
3696
- === TEST 61 : resolver send query failing immediately in connect()
3734
+ === TEST 62 : resolver send query failing immediately in connect()
3697
3735
this case did not clear coctx->cleanup properly and would lead to memory invalid accesses.
3698
3736
3699
3737
this test case requires the following iptables rule to work properly:
@@ -3730,7 +3768,7 @@ qr{\[alert\] .*? send\(\) failed \(\d+: Operation not permitted\) while resolvin
3730
3768
3731
3769
3732
3770
3733
- === TEST 62 : the upper bound of port range should be 2^16 - 1
3771
+ === TEST 63 : the upper bound of port range should be 2^16 - 1
3734
3772
--- config
3735
3773
location /t {
3736
3774
content_by_lua_block {
@@ -3749,7 +3787,7 @@ failed to connect: bad port number: 65536
3749
3787
3750
3788
3751
3789
3752
- === TEST 63 : send boolean and nil
3790
+ === TEST 64 : send boolean and nil
3753
3791
--- config
3754
3792
location /t {
3755
3793
set $port $TEST_NGINX_SERVER_PORT;
@@ -3811,7 +3849,7 @@ received: truefalsenil
3811
3849
3812
3850
3813
3851
3814
- === TEST 64 : receiveany method in cosocket
3852
+ === TEST 65 : receiveany method in cosocket
3815
3853
--- config
3816
3854
server_tokens off;
3817
3855
location = /t {
@@ -3900,7 +3938,7 @@ lua tcp socket read any
3900
3938
3901
3939
3902
3940
3903
- === TEST 65 : receiveany send data after read side closed
3941
+ === TEST 66 : receiveany send data after read side closed
3904
3942
--- config
3905
3943
server_tokens off;
3906
3944
location = /t {
@@ -3944,7 +3982,7 @@ GET /t
3944
3982
3945
3983
3946
3984
3947
- === TEST 66 : receiveany with limited, max <= 0
3985
+ === TEST 67 : receiveany with limited, max <= 0
3948
3986
--- config
3949
3987
location = /t {
3950
3988
set $port $TEST_NGINX_SERVER_PORT;
@@ -3980,7 +4018,7 @@ GET /t
3980
4018
3981
4019
3982
4020
3983
- === TEST 67 : receiveany with limited, max is larger than data
4021
+ === TEST 68 : receiveany with limited, max is larger than data
3984
4022
--- config
3985
4023
server_tokens off;
3986
4024
location = /t {
@@ -4049,7 +4087,7 @@ lua tcp socket calling receiveany() method to read at most 128 bytes
4049
4087
4050
4088
4051
4089
4052
- === TEST 68 : receiveany with limited, max is smaller than data
4090
+ === TEST 69 : receiveany with limited, max is smaller than data
4053
4091
--- config
4054
4092
server_tokens off;
4055
4093
location = /t {
0 commit comments