Skip to content

Commit

Permalink
PR comments.
Browse files Browse the repository at this point in the history
Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>
  • Loading branch information
Yury-Fridlyand committed Mar 8, 2024
1 parent 88277c1 commit 93186f3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions csharp/lib/AsyncClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ private void SuccessCallback(ulong index, IntPtr str)
});
}

private void FailureCallback(ulong index, ErrorType error_type, IntPtr ptr)
private void FailureCallback(ulong index, ErrorType error_type, IntPtr error_msg_ptr)
{
var error = ptr == IntPtr.Zero ? null : Marshal.PtrToStringAnsi(ptr);
var error = error_msg_ptr == IntPtr.Zero ? null : Marshal.PtrToStringAnsi(error_msg_ptr);
// Work needs to be offloaded from the calling thread, because otherwise we might starve the client's thread pool.
_ = Task.Run(() => messageContainer.GetMessage((int)index)
.SetException(Errors.MakeException(error_type, error)));
Expand Down Expand Up @@ -98,8 +98,8 @@ private void FailureCallback(ulong index, ErrorType error_type, IntPtr ptr)
/// </summary>
/// <param name="index">Request ID</param>
/// <param name="error_type">Error type</param>
/// <param name="error">Error message</param>
private delegate void FailureAction(ulong index, ErrorType error_type, IntPtr error);
/// <param name="error_msg_ptr">Error message</param>
private delegate void FailureAction(ulong index, ErrorType error_type, IntPtr error_msg_ptr);
[DllImport("libglide_rs", CallingConvention = CallingConvention.Cdecl, EntryPoint = "get")]
private static extern void GetFfi(IntPtr client, ulong index, IntPtr key);

Expand Down
12 changes: 6 additions & 6 deletions csharp/lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ pub extern "C" fn set(
match result {
Ok(_) => (client.success_callback)(callback_index, std::ptr::null()), // TODO - should return "OK" string.
Err(err) => {
logger_core::log_debug("command error", format!("callback {}, error {}, kind {:?}, code {:?}, category {:?}, detail {:?}", callback_index, err, err.kind(), err.code(), err.category(), err.detail()));
let c_err_str = CString::new(error_message(&err)).expect("CString::new failed");
logger_core::log_debug("command error", format!("callback: {}, error: {}", callback_index, err));
let c_err_str = CString::new(error_message(&err)).unwrap();
(client.failure_callback)(callback_index, error_type(&err), c_err_str.as_ptr())
}
};
Expand Down Expand Up @@ -149,8 +149,8 @@ pub extern "C" fn get(client_ptr: *const c_void, callback_index: usize, key: *co
Ok(value) => value,
Err(err) => {
unsafe {
logger_core::log_debug("command error", format!("callback {}, error {}, kind {:?}, code {:?}, category {:?}, detail {:?}", callback_index, err, err.kind(), err.code(), err.category(), err.detail()));
let c_err_str = CString::new(error_message(&err)).expect("CString::new failed");
logger_core::log_debug("command error", format!("callback: {}, error: {}", callback_index, err));
let c_err_str = CString::new(error_message(&err)).unwrap();
(client.failure_callback)(callback_index, error_type(&err), c_err_str.as_ptr())
};
return;
Expand All @@ -163,8 +163,8 @@ pub extern "C" fn get(client_ptr: *const c_void, callback_index: usize, key: *co
Ok(None) => (client.success_callback)(callback_index, std::ptr::null()),
Ok(Some(c_str)) => (client.success_callback)(callback_index, c_str.as_ptr()),
Err(err) => {
logger_core::log_debug("command error", format!("callback {}, error {}, kind {:?}, code {:?}, category {:?}, detail {:?}", callback_index, err, err.kind(), err.code(), err.category(), err.detail()));
let c_err_str = CString::new(error_message(&err)).expect("CString::new failed");
logger_core::log_debug("command error", format!("callback: {}, error: {}", callback_index, err));
let c_err_str = CString::new(error_message(&err)).unwrap();
(client.failure_callback)(callback_index, error_type(&err), c_err_str.as_ptr())
}
};
Expand Down

0 comments on commit 93186f3

Please sign in to comment.