Skip to content

Commit

Permalink
Safe wrapping for MustCatchup field in FABRIC_REPLICA_INFORMATION_EX1 (
Browse files Browse the repository at this point in the history
…#40)

Fixes #39
  • Loading branch information
youyuanwu authored Jun 20, 2024
1 parent 32fde93 commit 1a52ebb
Show file tree
Hide file tree
Showing 4 changed files with 218 additions and 83 deletions.
90 changes: 42 additions & 48 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/libs/core/src/client/svc_mgmt_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ impl ResolvedServicePartition {
}
}

#[derive(Debug)]
#[derive(Debug, PartialEq, Clone)]
pub enum ServiceEndpointRole {
Invalid,
StatefulPrimary,
Expand Down
20 changes: 12 additions & 8 deletions crates/libs/core/src/runtime/stateful_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
// stateful_proxy is a wrapper layer around com api,
// making manipulating com simple.

use std::ffi::c_void;

use mssf_com::{
FabricCommon::FabricRuntime::{
IFabricPrimaryReplicator, IFabricReplicator, IFabricStatefulServiceReplica,
Expand Down Expand Up @@ -235,9 +237,12 @@ impl PrimaryReplicator for PrimaryReplicatorProxy {
previousconfiguration: &ReplicaSetConfig,
) -> ::windows_core::Result<()> {
info!("PrimaryReplicatorProxy::update_catch_up_replica_set_configuration");
let cc = currentconfiguration.get_raw();
let pc = previousconfiguration.get_raw();
unsafe { self.com_impl.UpdateCatchUpReplicaSetConfiguration(&cc, &pc) }
let cc_view = currentconfiguration.get_view();
let pc_view = previousconfiguration.get_view();
unsafe {
self.com_impl
.UpdateCatchUpReplicaSetConfiguration(cc_view.get_raw(), pc_view.get_raw())
}
}
async fn wait_for_catch_up_quorum(
&self,
Expand Down Expand Up @@ -266,7 +271,7 @@ impl PrimaryReplicator for PrimaryReplicatorProxy {
info!("PrimaryReplicatorProxy::update_current_replica_set_configuration");
unsafe {
self.com_impl
.UpdateCurrentReplicaSetConfiguration(&currentconfiguration.get_raw())
.UpdateCurrentReplicaSetConfiguration(currentconfiguration.get_view().get_raw())
}
}
async fn build_replica(&self, replica: &ReplicaInfo) -> ::windows_core::Result<()> {
Expand All @@ -279,10 +284,9 @@ impl PrimaryReplicator for PrimaryReplicatorProxy {
}
});
{
let _ = unsafe {
self.com_impl
.BeginBuildReplica(&replica.get_raw(), &callback)?
};
let (mut info, ex1) = replica.get_raw_parts();
info.Reserved = std::ptr::addr_of!(ex1) as *mut c_void;
let _ = unsafe { self.com_impl.BeginBuildReplica(&info, &callback)? };
}
rx.await.unwrap()
}
Expand Down
Loading

0 comments on commit 1a52ebb

Please sign in to comment.