Fix the Sync issue. Details:

So the HTTP client future of Hyper is not Sync, thus the stream
that read blocks wasn't either. However Hyper's default Body type
requires a stream to be Sync for wrap_stream. Solution: reimplement
a custom HTTP body type.
This commit is contained in:
Alex Auvolat
2020-04-10 22:01:48 +02:00
parent d66c0d6833
commit 3477864142
14 changed files with 663 additions and 432 deletions
+12 -8
View File
@@ -1,12 +1,11 @@
use std::sync::Arc;
use serde::{Serialize, Deserialize};
use async_trait::async_trait;
use serde::{Deserialize, Serialize};
use std::sync::Arc;
use tokio::sync::RwLock;
use crate::data::*;
use crate::table::*;
use crate::server::Garage;
use crate::table::*;
#[derive(PartialEq, Clone, Debug, Serialize, Deserialize)]
pub struct Object {
@@ -35,7 +34,7 @@ pub struct ObjectVersion {
#[derive(PartialEq, Clone, Debug, Serialize, Deserialize)]
pub enum ObjectVersionData {
DeleteMarker,
Inline(#[serde(with="serde_bytes")] Vec<u8>),
Inline(#[serde(with = "serde_bytes")] Vec<u8>),
FirstBlock(Hash),
}
@@ -49,7 +48,9 @@ impl Entry<String, String> for Object {
fn merge(&mut self, other: &Self) {
for other_v in other.versions.iter() {
match self.versions.binary_search_by(|v| (v.timestamp, &v.uuid).cmp(&(other_v.timestamp, &other_v.uuid))) {
match self.versions.binary_search_by(|v| {
(v.timestamp, &v.uuid).cmp(&(other_v.timestamp, &other_v.uuid))
}) {
Ok(i) => {
let mut v = &mut self.versions[i];
if other_v.size > v.size {
@@ -64,8 +65,11 @@ impl Entry<String, String> for Object {
}
}
}
let last_complete = self.versions
.iter().enumerate().rev()
let last_complete = self
.versions
.iter()
.enumerate()
.rev()
.filter(|(_, v)| v.is_complete)
.next()
.map(|(vi, _)| vi);