Split _wait and _unref

This also removes BackupProvider::join in favour of implementing
Future directly.  I wondered about implementing a FusedFutre to make
this a little safer but it would introduce a dependency on the futures
crate in deltachat-ffi which did not exist yet, so I didn't do that.
This commit is contained in:
Floris Bruynooghe
2023-02-20 15:56:05 +01:00
parent 73b90eee3e
commit b920db12c7
5 changed files with 31 additions and 14 deletions

View File

@@ -4185,12 +4185,17 @@ pub unsafe extern "C" fn dc_backup_provider_wait(
return;
}
let ctx = &*context;
let provider = Box::from_raw(provider);
block_on(provider.join())
let provider = &mut *provider;
block_on(provider)
.log_err(ctx, "Failed to join provider")
.ok();
}
#[no_mangle]
pub unsafe extern "C" fn dc_backup_provider_unref(provider: *mut dc_backup_provider_t) {
drop(Box::from_raw(provider));
}
#[no_mangle]
pub unsafe extern "C" fn dc_receive_backup(
context: *mut dc_context_t,