@@ -18,6 +18,7 @@ mod utils;
1818use log:: LevelFilter ;
1919use protocols:: sync:: { agent, agent_ttrpc, health, health_ttrpc} ;
2020use std:: thread;
21+ use std:: time:: Duration ;
2122use ttrpc:: context:: { self , Context } ;
2223use ttrpc:: error:: Error ;
2324use ttrpc:: proto:: Code ;
@@ -38,18 +39,12 @@ fn get_fd_count() -> usize {
3839}
3940
4041fn main ( ) {
41- connect_once ( ) ;
4242 let expected_fd_count = get_fd_count ( ) ;
43-
44- // connect 3 times and check the fd leak.
45- for index in 0 ..3 {
46- connect_once ( ) ;
47- let current_fd_count = get_fd_count ( ) ;
48- assert_eq ! (
49- expected_fd_count, current_fd_count,
50- "check fd count in {index}"
51- ) ;
52- }
43+ connect_once ( ) ;
44+ // Give some time for fd to be released in the other thread
45+ thread:: sleep ( Duration :: from_secs ( 1 ) ) ;
46+ let current_fd_count = get_fd_count ( ) ;
47+ assert_eq ! ( current_fd_count, expected_fd_count, "check fd count" ) ;
5348}
5449
5550fn connect_once ( ) {
@@ -151,9 +146,6 @@ fn connect_once() {
151146 now. elapsed( )
152147 ) ;
153148
154- println ! ( "\n sleep 2 seconds ...\n " ) ;
155- thread:: sleep ( std:: time:: Duration :: from_secs ( 2 ) ) ;
156-
157149 let version = hc. version ( default_ctx ( ) , & health:: CheckRequest :: new ( ) ) ;
158150 assert_eq ! ( "mock.0.1" , version. as_ref( ) . unwrap( ) . agent_version. as_str( ) ) ;
159151 assert_eq ! ( "0.0.1" , version. as_ref( ) . unwrap( ) . grpc_version. as_str( ) ) ;
0 commit comments