Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3345738
D5093.id16574.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D5093.id16574.diff
View Options
diff --git a/services/backup/blob_client/src/put_client.rs b/services/backup/blob_client/src/put_client.rs
--- a/services/backup/blob_client/src/put_client.rs
+++ b/services/backup/blob_client/src/put_client.rs
@@ -9,8 +9,10 @@
use crate::constants::{BLOB_ADDRESS, MPSC_CHANNEL_BUFFER_CAPACITY};
use crate::tools::{
- c_char_pointer_to_string, check_error, report_error, string_to_c_char_pointer,
+ c_char_pointer_to_string, c_char_pointer_to_string_new, check_error,
+ report_error, string_to_c_char_pointer, string_to_c_char_pointer_new,
};
+use anyhow::bail;
use lazy_static::lazy_static;
use libc;
use libc::c_char;
@@ -31,7 +33,7 @@
tx: mpsc::Sender<PutRequestData>,
rx: mpsc::Receiver<String>,
- rx_handle: JoinHandle<()>,
+ rx_handle: JoinHandle<()>, //<anyhow::Result<(), anyhow::Error>>,
}
lazy_static! {
@@ -54,12 +56,21 @@
}
}
+fn is_initialized_new(holder: &str) -> anyhow::Result<bool, anyhow::Error> {
+ return Ok(match CLIENTS.lock() {
+ Ok(clients) => clients.contains_key(holder),
+ _ => {
+ bail!("couldn't access client");
+ }
+ });
+}
+
pub fn put_client_initialize_cxx(
holder_char: *const c_char,
) -> Result<(), String> {
let holder = c_char_pointer_to_string(holder_char)?;
if is_initialized(&holder) {
- put_client_terminate_cxx(string_to_c_char_pointer(&holder)?)?;
+ // put_client_terminate_cxx(string_to_c_char_pointer(&holder)?)?;
}
assert!(
!is_initialized(&holder),
@@ -272,11 +283,9 @@
pub fn put_client_terminate_cxx(
holder_char: *const c_char,
-) -> Result<(), String> {
- let holder = c_char_pointer_to_string(holder_char)?;
- check_error(&ERROR_MESSAGES)?;
- if !is_initialized(&holder) {
- check_error(&ERROR_MESSAGES)?;
+) -> anyhow::Result<(), anyhow::Error> {
+ let holder = c_char_pointer_to_string_new(holder_char)?;
+ if !is_initialized_new(&holder)? {
return Ok(());
}
@@ -286,24 +295,19 @@
drop(client.tx);
RUNTIME.block_on(async {
if client.rx_handle.await.is_err() {
- report_error(
- &ERROR_MESSAGES,
- "wait for receiver handle failed",
- Some("put"),
- );
+ bail!(format!("awaiting for the client {} failed", holder));
}
- });
+ Ok(())
+ })?;
} else {
- return Err("no client detected in terminate".to_string());
+ bail!("no client detected in terminate");
}
} else {
- return Err("couldn't access client".to_string());
+ bail!("couldn't access client");
}
- assert!(
- !is_initialized(&holder),
- "client transmitter handler released properly"
- );
- check_error(&ERROR_MESSAGES)?;
+ if is_initialized_new(&holder)? {
+ bail!("client transmitter handler released properly");
+ }
Ok(())
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 23, 6:46 AM (18 h, 11 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2569509
Default Alt Text
D5093.id16574.diff (2 KB)
Attached To
Mode
D5093: [services] Backup - Blob Get Client - Refactor put terminate
Attached
Detach File
Event Timeline
Log In to Comment