@@ -29,7 +29,7 @@ our $StapScript = $t::StapThread::StapScript;
29
29
30
30
repeat_each(2 );
31
31
32
- plan tests => repeat_each() * (blocks() * 4 + 13 );
32
+ plan tests => repeat_each() * (blocks() * 4 + 12 );
33
33
34
34
our $ HtmlDir = html_dir;
35
35
@@ -48,7 +48,7 @@ __DATA__
48
48
server_tokens off;
49
49
lua_socket_connect_timeout 100 ms;
50
50
resolver $ TEST_NGINX_RESOLVER ;
51
- resolver_timeout 1 s ;
51
+ resolver_timeout 3 s ;
52
52
location / t {
53
53
content_by_lua '
54
54
local sock = ngx.socket.tcp()
@@ -76,6 +76,7 @@ lua tcp socket connect timed out
76
76
server_tokens off;
77
77
lua_socket_connect_timeout 60 s;
78
78
resolver $ TEST_NGINX_RESOLVER ;
79
+ resolver_timeout 3 s;
79
80
location / t {
80
81
content_by_lua '
81
82
local sock = ngx.socket.tcp()
@@ -685,7 +686,7 @@ after
685
686
server_tokens off;
686
687
lua_socket_connect_timeout 100 ms;
687
688
resolver $ TEST_NGINX_RESOLVER ;
688
- resolver_timeout 1 s ;
689
+ resolver_timeout 3 s ;
689
690
location / t {
690
691
content_by_lua '
691
692
local sock = ngx.socket.tcp()
@@ -918,3 +919,71 @@ lua tcp socket read timeout: 10
918
919
lua tcp socket connect timeout: 60000
919
920
lua tcp socket read timed out
920
921
922
+
923
+
924
+ === TEST 22 : concurrent operations while writing
925
+ -- - config
926
+ server_tokens off;
927
+ lua_socket_log_errors off;
928
+ location / t {
929
+ content_by_lua '
930
+ local sock = ngx.socket.tcp()
931
+
932
+ local function f()
933
+ ngx.sleep(0.01)
934
+ local bytes, err = sock:send("flush_all")
935
+ ngx.say("send: ", bytes, " ", err)
936
+
937
+ local ok, err = sock:close()
938
+ ngx.say("close: ", ok, " ", err)
939
+
940
+ local ok, err = sock:getreusedtimes()
941
+ ngx.say("getreusedtimes: ", ok, " ", err)
942
+
943
+ local ok, err = sock:setkeepalive()
944
+ ngx.say("setkeepalive: ", ok, " ", err)
945
+
946
+ local ok, err = sock:connect("127.0.0.1", $TEST_NGINX_MEMCACHED_PORT)
947
+ ngx.say("connect: ", ok, " ", err)
948
+
949
+ sock:settimeout(1)
950
+ local res, err = sock:receive(1)
951
+ ngx.say("receive: ", res, " ", err)
952
+ end
953
+
954
+ local ok, err = ngx.thread.spawn(f)
955
+ if not ok then
956
+ ngx.say("failed to spawn writer thread: ", err)
957
+ return
958
+ end
959
+
960
+ sock:settimeout(300)
961
+ local ok, err = sock:connect("127.0.0.1", $TEST_NGINX_MEMCACHED_PORT)
962
+ ngx.say("connect: ", ok, " ", err)
963
+
964
+ local bytes, err = sock:send("get helloworld!")
965
+ if not bytes then
966
+ ngx.say("send failed: ", err)
967
+ end
968
+
969
+ local ok, err = sock:close()
970
+ ngx.say("close: ", ok, " ", err)
971
+ ' ;
972
+ }
973
+
974
+ -- - request
975
+ GET / t
976
+ -- - response_body
977
+ connect : 1 nil
978
+ send: nil socket busy writing
979
+ close : nil socket busy writing
980
+ getreusedtimes: 0 nil
981
+ setkeepalive: nil socket busy writing
982
+ connect : nil socket busy writing
983
+ receive: nil timeout
984
+ send failed: timeout
985
+ close : 1 nil
986
+
987
+ -- - no_error_log
988
+ [error]
989
+
0 commit comments