@@ -112,6 +112,24 @@ struct ClientTaskHandle {
112
112
client_stop_tx : Option < oneshot:: Sender < ClientStopReason > > ,
113
113
}
114
114
115
+ #[ derive( Debug ) ]
116
+ pub struct ConnectionId ( pub u64 ) ;
117
+
118
+ impl std:: fmt:: Display for ConnectionId {
119
+ fn fmt (
120
+ & self ,
121
+ f : & mut std:: fmt:: Formatter < ' _ > ,
122
+ ) -> Result < ( ) , std:: fmt:: Error > {
123
+ self . 0 . fmt ( f)
124
+ }
125
+ }
126
+
127
+ impl ConnectionId {
128
+ fn update ( & mut self ) {
129
+ self . 0 += 1 ;
130
+ }
131
+ }
132
+
115
133
/// Per-client data
116
134
///
117
135
/// This data structure contains client-specific state and manages communication
@@ -197,7 +215,7 @@ pub(crate) struct DownstairsClient {
197
215
negotiation_state : NegotiationState ,
198
216
199
217
/// Session ID for a clients connection to a downstairs.
200
- connection_id : usize ,
218
+ connection_id : ConnectionId ,
201
219
}
202
220
203
221
impl DownstairsClient {
@@ -234,7 +252,7 @@ impl DownstairsClient {
234
252
region_metadata : None ,
235
253
repair_info : None ,
236
254
io_state_count : ClientIOStateCount :: new ( ) ,
237
- connection_id : 0 ,
255
+ connection_id : ConnectionId ( 0 ) ,
238
256
}
239
257
}
240
258
@@ -271,7 +289,7 @@ impl DownstairsClient {
271
289
region_metadata : None ,
272
290
repair_info : None ,
273
291
io_state_count : ClientIOStateCount :: new ( ) ,
274
- connection_id : 0 ,
292
+ connection_id : ConnectionId ( 0 ) ,
275
293
}
276
294
}
277
295
@@ -609,7 +627,7 @@ impl DownstairsClient {
609
627
self . state = DsState :: New ;
610
628
}
611
629
612
- self . connection_id += 1 ;
630
+ self . connection_id . update ( ) ;
613
631
// Restart with a short delay
614
632
self . start_task ( true , auto_promote) ;
615
633
}
@@ -2197,7 +2215,7 @@ impl DownstairsClient {
2197
2215
/// different connections to the same Downstairs.
2198
2216
pub ( crate ) fn get_connection_id ( & self ) -> Option < u64 > {
2199
2217
if self . client_task . client_stop_tx . is_some ( ) {
2200
- Some ( self . connection_id as u64 )
2218
+ Some ( self . connection_id . 0 )
2201
2219
} else {
2202
2220
None
2203
2221
}
0 commit comments