Skip to content

Commit 1efa9b9

Browse files
committed
server: fix the issue of failed to trigger client handler
Since the sync channel with a buffer size of 0 will become "rendezvous channel" where a try_send would return directly with an error when its peer receiver isn't waiting to acquire some data, and in this case there would be chance to miss trigger client handler to create much more worker threads to handle the request messages. Thus, it should use "send" to block until its peer receiver is available to hand off the message. Signed-off-by: fupan.lfp <fupan.lfp@antfin.com>
1 parent 5185359 commit 1efa9b9

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/sync/server.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ fn start_method_handler_thread(
110110
if quit.load(Ordering::SeqCst) {
111111
// notify the connection dealing main thread to stop.
112112
control_tx
113-
.try_send(())
113+
.send(())
114114
.unwrap_or_else(|err| debug!("Failed to try send {:?}", err));
115115
break;
116116
}
@@ -120,15 +120,16 @@ fn start_method_handler_thread(
120120
if quit.load(Ordering::SeqCst) {
121121
// notify the connection dealing main thread to stop.
122122
control_tx
123-
.try_send(())
123+
.send(())
124124
.unwrap_or_else(|err| debug!("Failed to try send {:?}", err));
125125
break;
126126
}
127127

128128
let c = wtc.fetch_sub(1, Ordering::SeqCst) - 1;
129129
if c < min {
130+
trace!("notify client handler to create much more worker threads!");
130131
control_tx
131-
.try_send(())
132+
.send(())
132133
.unwrap_or_else(|err| debug!("Failed to try send {:?}", err));
133134
}
134135

@@ -147,7 +148,7 @@ fn start_method_handler_thread(
147148
// the connection dealing main thread would
148149
// have exited.
149150
control_tx
150-
.try_send(())
151+
.send(())
151152
.unwrap_or_else(|err| debug!("Failed to try send {:?}", err));
152153
break;
153154
}
@@ -174,7 +175,7 @@ fn start_method_handler_thread(
174175
// the connection dealing main thread would have
175176
// exited.
176177
control_tx
177-
.try_send(())
178+
.send(())
178179
.unwrap_or_else(|err| debug!("Failed to try send {:?}", err));
179180
break;
180181
}
@@ -197,7 +198,7 @@ fn start_method_handler_thread(
197198
// the connection dealing main thread would have
198199
// exited.
199200
control_tx
200-
.try_send(())
201+
.send(())
201202
.unwrap_or_else(|err| debug!("Failed to try send {:?}", err));
202203
break;
203204
}
@@ -215,7 +216,7 @@ fn start_method_handler_thread(
215216
// the connection dealing main thread would have
216217
// exited.
217218
control_tx
218-
.try_send(())
219+
.send(())
219220
.unwrap_or_else(|err| debug!("Failed to try send {:?}", err));
220221
break;
221222
}

0 commit comments

Comments
 (0)