Merge pull request #2103 from zed-industries/connection-staleness
Fix connection staleness issues
This commit is contained in:
parent
03a8d0968c
commit
85456dfcaa
5 changed files with 22 additions and 19 deletions
|
@ -84,5 +84,3 @@ split-debuginfo = "unpacked"
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
debug = true
|
debug = true
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ WORKDIR app
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Compile collab server
|
# Compile collab server
|
||||||
|
ARG CARGO_PROFILE_RELEASE_PANIC=abort
|
||||||
RUN --mount=type=cache,target=./script/node_modules \
|
RUN --mount=type=cache,target=./script/node_modules \
|
||||||
--mount=type=cache,target=/usr/local/cargo/registry \
|
--mount=type=cache,target=/usr/local/cargo/registry \
|
||||||
--mount=type=cache,target=./target \
|
--mount=type=cache,target=./target \
|
||||||
|
|
|
@ -1586,12 +1586,8 @@ impl Database {
|
||||||
.filter(
|
.filter(
|
||||||
Condition::all()
|
Condition::all()
|
||||||
.add(
|
.add(
|
||||||
room_participant::Column::CallingConnectionId
|
room_participant::Column::CallingUserId
|
||||||
.eq(connection.id as i32),
|
.eq(leaving_participant.user_id),
|
||||||
)
|
|
||||||
.add(
|
|
||||||
room_participant::Column::CallingConnectionServerId
|
|
||||||
.eq(connection.owner_id as i32),
|
|
||||||
)
|
)
|
||||||
.add(room_participant::Column::AnsweringConnectionId.is_null()),
|
.add(room_participant::Column::AnsweringConnectionId.is_null()),
|
||||||
)
|
)
|
||||||
|
|
|
@ -166,12 +166,10 @@ async fn test_random_collaboration(
|
||||||
let contacts = server.app_state.db.get_contacts(*user_id).await.unwrap();
|
let contacts = server.app_state.db.get_contacts(*user_id).await.unwrap();
|
||||||
let pool = server.connection_pool.lock();
|
let pool = server.connection_pool.lock();
|
||||||
for contact in contacts {
|
for contact in contacts {
|
||||||
if let db::Contact::Accepted { user_id, .. } = contact {
|
if let db::Contact::Accepted { user_id, busy, .. } = contact {
|
||||||
if pool.is_user_online(user_id) {
|
if user_id == removed_user_id {
|
||||||
assert_ne!(
|
assert!(!pool.is_user_online(user_id));
|
||||||
user_id, removed_user_id,
|
assert!(!busy);
|
||||||
"removed client is still a contact of another peer"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ use std::fmt;
|
||||||
use std::{
|
use std::{
|
||||||
cmp,
|
cmp,
|
||||||
fmt::Debug,
|
fmt::Debug,
|
||||||
io, iter, mem,
|
io, iter,
|
||||||
time::{Duration, SystemTime, UNIX_EPOCH},
|
time::{Duration, SystemTime, UNIX_EPOCH},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -489,16 +489,26 @@ pub fn split_worktree_update(
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let chunk_size = cmp::min(message.updated_entries.len(), max_chunk_size);
|
let updated_entries_chunk_size = cmp::min(message.updated_entries.len(), max_chunk_size);
|
||||||
let updated_entries = message.updated_entries.drain(..chunk_size).collect();
|
let updated_entries = message
|
||||||
done = message.updated_entries.is_empty();
|
.updated_entries
|
||||||
|
.drain(..updated_entries_chunk_size)
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
let removed_entries_chunk_size = cmp::min(message.removed_entries.len(), max_chunk_size);
|
||||||
|
let removed_entries = message
|
||||||
|
.removed_entries
|
||||||
|
.drain(..removed_entries_chunk_size)
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
done = message.updated_entries.is_empty() && message.removed_entries.is_empty();
|
||||||
Some(UpdateWorktree {
|
Some(UpdateWorktree {
|
||||||
project_id: message.project_id,
|
project_id: message.project_id,
|
||||||
worktree_id: message.worktree_id,
|
worktree_id: message.worktree_id,
|
||||||
root_name: message.root_name.clone(),
|
root_name: message.root_name.clone(),
|
||||||
abs_path: message.abs_path.clone(),
|
abs_path: message.abs_path.clone(),
|
||||||
updated_entries,
|
updated_entries,
|
||||||
removed_entries: mem::take(&mut message.removed_entries),
|
removed_entries,
|
||||||
scan_id: message.scan_id,
|
scan_id: message.scan_id,
|
||||||
is_last_update: done && message.is_last_update,
|
is_last_update: done && message.is_last_update,
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue