@@ -18,6 +18,7 @@ mod utils;
18
18
use log:: LevelFilter ;
19
19
use protocols:: sync:: { agent, agent_ttrpc, health, health_ttrpc} ;
20
20
use std:: thread;
21
+ use std:: time:: Duration ;
21
22
use ttrpc:: context:: { self , Context } ;
22
23
use ttrpc:: error:: Error ;
23
24
use ttrpc:: proto:: Code ;
@@ -38,18 +39,12 @@ fn get_fd_count() -> usize {
38
39
}
39
40
40
41
fn main ( ) {
41
- connect_once ( ) ;
42
42
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" ) ;
53
48
}
54
49
55
50
fn connect_once ( ) {
@@ -151,9 +146,6 @@ fn connect_once() {
151
146
now. elapsed( )
152
147
) ;
153
148
154
- println ! ( "\n sleep 2 seconds ...\n " ) ;
155
- thread:: sleep ( std:: time:: Duration :: from_secs ( 2 ) ) ;
156
-
157
149
let version = hc. version ( default_ctx ( ) , & health:: CheckRequest :: new ( ) ) ;
158
150
assert_eq ! ( "mock.0.1" , version. as_ref( ) . unwrap( ) . agent_version. as_str( ) ) ;
159
151
assert_eq ! ( "0.0.1" , version. as_ref( ) . unwrap( ) . grpc_version. as_str( ) ) ;
0 commit comments