Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
c950826e46 | |||
f91d58e157 |
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "proxmox-backup"
|
name = "proxmox-backup"
|
||||||
version = "0.7.0"
|
version = "0.8.0"
|
||||||
authors = ["Dietmar Maurer <dietmar@proxmox.com>"]
|
authors = ["Dietmar Maurer <dietmar@proxmox.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "AGPL-3"
|
license = "AGPL-3"
|
||||||
|
6
debian/changelog
vendored
6
debian/changelog
vendored
@ -1,3 +1,9 @@
|
|||||||
|
rust-proxmox-backup (0.8.0-1) unstable; urgency=medium
|
||||||
|
|
||||||
|
* implement get_runtime_with_builder
|
||||||
|
|
||||||
|
-- Proxmox Support Team <support@proxmox.com> Tue, 07 Jul 2020 10:15:26 +0200
|
||||||
|
|
||||||
rust-proxmox-backup (0.7.0-1) unstable; urgency=medium
|
rust-proxmox-backup (0.7.0-1) unstable; urgency=medium
|
||||||
|
|
||||||
* implement clone for RemoteChunkReader
|
* implement clone for RemoteChunkReader
|
||||||
|
@ -56,30 +56,41 @@ extern {
|
|||||||
///
|
///
|
||||||
/// This makes sure that tokio's worker threads are marked for us so that we know whether we
|
/// This makes sure that tokio's worker threads are marked for us so that we know whether we
|
||||||
/// can/need to use `block_in_place` in our `block_on` helper.
|
/// can/need to use `block_in_place` in our `block_on` helper.
|
||||||
pub fn get_runtime() -> Arc<Runtime> {
|
pub fn get_runtime_with_builder<F: Fn() -> runtime::Builder>(get_builder: F) -> Arc<Runtime> {
|
||||||
|
|
||||||
let mut guard = RUNTIME.lock().unwrap();
|
let mut guard = RUNTIME.lock().unwrap();
|
||||||
|
|
||||||
if let Some(rt) = guard.upgrade() { return rt; }
|
if let Some(rt) = guard.upgrade() { return rt; }
|
||||||
|
|
||||||
let rt = Arc::new(
|
let mut builder = get_builder();
|
||||||
runtime::Builder::new()
|
builder.on_thread_stop(|| {
|
||||||
.on_thread_stop(|| {
|
// avoid openssl bug: https://github.com/openssl/openssl/issues/6214
|
||||||
// avoid openssl bug: https://github.com/openssl/openssl/issues/6214
|
// call OPENSSL_thread_stop to avoid race with openssl cleanup handlers
|
||||||
// call OPENSSL_thread_stop to avoid race with openssl cleanup handlers
|
unsafe { OPENSSL_thread_stop(); }
|
||||||
unsafe { OPENSSL_thread_stop(); }
|
});
|
||||||
})
|
|
||||||
.threaded_scheduler()
|
let runtime = builder.build().expect("failed to spawn tokio runtime");
|
||||||
.enable_all()
|
let rt = Arc::new(runtime);
|
||||||
.build()
|
|
||||||
.expect("failed to spawn tokio runtime")
|
|
||||||
);
|
|
||||||
|
|
||||||
*guard = Arc::downgrade(&rt.clone());
|
*guard = Arc::downgrade(&rt.clone());
|
||||||
|
|
||||||
rt
|
rt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get or create the current main tokio runtime.
|
||||||
|
///
|
||||||
|
/// This calls get_runtime_with_builder() using the tokio default threaded scheduler
|
||||||
|
pub fn get_runtime() -> Arc<Runtime> {
|
||||||
|
|
||||||
|
get_runtime_with_builder(|| {
|
||||||
|
let mut builder = runtime::Builder::new();
|
||||||
|
builder.threaded_scheduler();
|
||||||
|
builder.enable_all();
|
||||||
|
builder
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Block on a synchronous piece of code.
|
/// Block on a synchronous piece of code.
|
||||||
pub fn block_in_place<R>(fut: impl FnOnce() -> R) -> R {
|
pub fn block_in_place<R>(fut: impl FnOnce() -> R) -> R {
|
||||||
// don't double-exit the context (tokio doesn't like that)
|
// don't double-exit the context (tokio doesn't like that)
|
||||||
|
Reference in New Issue
Block a user