Skip to content

Commit 1786480

Browse files
authored
Merge pull request #136 from Tim-Zhang/downgrade-log-level
sync-server: downgrade level for log "Failed to send"
2 parents e5a5373 + 15f93ab commit 1786480

File tree

2 files changed

+16
-20
lines changed

2 files changed

+16
-20
lines changed

src/sync/client.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -225,19 +225,16 @@ impl Client {
225225
.send((buf, tx))
226226
.map_err(err_to_others_err!(e, "Send packet to sender error "))?;
227227

228-
let result: Result<Vec<u8>>;
229-
if req.timeout_nano == 0 {
230-
result = rx
231-
.recv()
232-
.map_err(err_to_others_err!(e, "Receive packet from recver error: "))?;
228+
let result = if req.timeout_nano == 0 {
229+
rx.recv()
230+
.map_err(err_to_others_err!(e, "Receive packet from recver error: "))?
233231
} else {
234-
result = rx
235-
.recv_timeout(Duration::from_nanos(req.timeout_nano as u64))
232+
rx.recv_timeout(Duration::from_nanos(req.timeout_nano as u64))
236233
.map_err(err_to_others_err!(
237234
e,
238235
"Receive packet from recver timeout: "
239-
))?;
240-
}
236+
))?
237+
};
241238

242239
let buf = result?;
243240
let mut s = CodedInputStream::from_bytes(&buf);

src/sync/server.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ fn start_method_handler_thread(
114114
// notify the connection dealing main thread to stop.
115115
control_tx
116116
.send(())
117-
.unwrap_or_else(|err| debug!("Failed to send {:?}", err));
117+
.unwrap_or_else(|err| trace!("Failed to send {:?}", err));
118118
break;
119119
}
120120
result = read_message(fd);
@@ -124,7 +124,7 @@ fn start_method_handler_thread(
124124
// notify the connection dealing main thread to stop.
125125
control_tx
126126
.send(())
127-
.unwrap_or_else(|err| debug!("Failed to send {:?}", err));
127+
.unwrap_or_else(|err| trace!("Failed to send {:?}", err));
128128
break;
129129
}
130130

@@ -133,7 +133,7 @@ fn start_method_handler_thread(
133133
trace!("notify client handler to create much more worker threads!");
134134
control_tx
135135
.send(())
136-
.unwrap_or_else(|err| debug!("Failed to send {:?}", err));
136+
.unwrap_or_else(|err| trace!("Failed to send {:?}", err));
137137
}
138138

139139
let mh;
@@ -152,7 +152,7 @@ fn start_method_handler_thread(
152152
// have exited.
153153
control_tx
154154
.send(())
155-
.unwrap_or_else(|err| debug!("Failed to send {:?}", err));
155+
.unwrap_or_else(|err| trace!("Failed to send {:?}", err));
156156
trace!("Socket error send control_tx");
157157
break;
158158
}
@@ -180,17 +180,16 @@ fn start_method_handler_thread(
180180
// exited.
181181
control_tx
182182
.send(())
183-
.unwrap_or_else(|err| debug!("Failed to send {:?}", err));
183+
.unwrap_or_else(|err| trace!("Failed to send {:?}", err));
184184
break;
185185
}
186186
continue;
187187
}
188188
trace!("Got Message request {:?}", req);
189189

190190
let path = format!("/{}/{}", req.service, req.method);
191-
let method;
192-
if let Some(x) = methods.get(&path) {
193-
method = x;
191+
let method = if let Some(x) = methods.get(&path) {
192+
x
194193
} else {
195194
let status = get_status(Code::INVALID_ARGUMENT, format!("{} does not exist", path));
196195
let mut res = Response::new();
@@ -203,11 +202,11 @@ fn start_method_handler_thread(
203202
// exited.
204203
control_tx
205204
.send(())
206-
.unwrap_or_else(|err| debug!("Failed to send {:?}", err));
205+
.unwrap_or_else(|err| trace!("Failed to send {:?}", err));
207206
break;
208207
}
209208
continue;
210-
}
209+
};
211210
let ctx = TtrpcContext {
212211
fd,
213212
mh,
@@ -223,7 +222,7 @@ fn start_method_handler_thread(
223222
// exited.
224223
control_tx
225224
.send(())
226-
.unwrap_or_else(|err| debug!("Failed to send {:?}", err));
225+
.unwrap_or_else(|err| trace!("Failed to send {:?}", err));
227226
break;
228227
}
229228
}

0 commit comments

Comments
 (0)