bg check ajustments
This commit is contained in:
1 parent
7eed94d82c
commit
923f4e397e
14 files changed
+649
-46
No files matched your search
@@ -205,13 +205,18 @@ async fn pull(st: &AppState, request_id: &[u8], p: v2::Pull, now: u64) -> HResul
|
||||
let sign = st.keys.sign.public();
|
||||
let mut mailboxes = Vec::with_capacity(p.auths.len());
|
||||
for a in &p.auths {
|
||||
if a.acks.len() > st.limits.max_acks || a.acks.iter().any(|id| id.len() > 64) {
|
||||
if a.acks.len() > st.limits.max_acks || a.acks.iter().any(|id| id.len() > 64) || a.after.len() > 64 {
|
||||
return Err((Code::BadRequest, "bad acks"));
|
||||
}
|
||||
let mb = rpc::verify_mailbox_auth(&sign, request_id, a, now)
|
||||
.map_err(|_| (Code::Unauthorized, "bad mailbox auth"))?;
|
||||
mailboxes.push(mb.0);
|
||||
}
|
||||
let cursors: Vec<(Mailbox, Vec<u8>)> = mailboxes
|
||||
.iter()
|
||||
.zip(&p.auths)
|
||||
.map(|(m, a)| (*m, a.after.clone()))
|
||||
.collect();
|
||||
// Acknowledged messages were persisted by the client: delete them first.
|
||||
for (mb, a) in mailboxes.iter().zip(&p.auths) {
|
||||
if !a.acks.is_empty() {
|
||||
@@ -221,7 +226,7 @@ async fn pull(st: &AppState, request_id: &[u8], p: v2::Pull, now: u64) -> HResul
|
||||
// Subscribe before reading, so a deposit landing in between is not missed.
|
||||
let mut rx = st.notify.subscribe();
|
||||
let limit = st.limits.max_pull_messages;
|
||||
let mut messages = st.store.fetch(&mailboxes, limit + 1).await.map_err(store_err)?;
|
||||
let mut messages = st.store.fetch(&cursors, limit + 1).await.map_err(store_err)?;
|
||||
let wait = Duration::from_secs(p.wait_seconds as u64).min(st.limits.max_wait);
|
||||
if messages.is_empty() && !wait.is_zero() {
|
||||
let wanted: HashSet<Mailbox> = mailboxes.iter().copied().collect();
|
||||
@@ -236,7 +241,7 @@ async fn pull(st: &AppState, request_id: &[u8], p: v2::Pull, now: u64) -> HResul
|
||||
}
|
||||
})
|
||||
.await;
|
||||
messages = st.store.fetch(&mailboxes, limit + 1).await.map_err(store_err)?;
|
||||
messages = st.store.fetch(&cursors, limit + 1).await.map_err(store_err)?;
|
||||
}
|
||||
// Honour the count and size budgets; always return at least one message.
|
||||
let mut more = messages.len() > limit;
|
||||
|
||||
Reference in new issue
Block a user