Implement SMB 3.x Lease support Phase 5
Some checks failed
Test / test (push) Has been cancelled
Test / build (push) Has been cancelled

- WRITE handler trigger lease break (READ leases conflict with WRITE)
- READ handler trigger lease break (HANDLE leases may conflict)
- Send LeaseBreakNotification via notification channel

All 229 tests pass.
This commit is contained in:
Warren
2026-06-21 01:24:59 +08:00
parent 4620475ba8
commit c3e21560b6
2 changed files with 34 additions and 0 deletions

View File

@@ -59,6 +59,24 @@ pub async fn handle(
}
}
// Phase 5: Trigger lease break if lease exists (SMB 3.x)
// READ operation doesn't break WRITE leases (only WRITE/HANDLE operations do)
// But we still check for HANDLE lease conflicts
let lease_notifications = server.lease_manager.break_lease(
crate::oplock::SMB2_LEASE_HANDLE, // READ operation may break HANDLE leases
).await;
for lease_notification in lease_notifications {
use crate::proto::framing::encode_frame;
let notification_bytes = lease_notification.write_to_bytes();
let mut frame = Vec::with_capacity(notification_bytes.len() + 4);
encode_frame(&notification_bytes, &mut frame);
if let Some(tx) = conn.notification_tx.read().await.as_ref() {
let _ = tx.send(frame).await;
}
}
let result = {
let open = open_arc.read().await;
match open.handle.as_ref() {

View File

@@ -75,6 +75,22 @@ pub async fn handle(
}
}
// Phase 5: Trigger lease break if lease exists (SMB 3.x)
let lease_notifications = server.lease_manager.break_lease(
crate::oplock::SMB2_LEASE_READ, // WRITE operation breaks READ leases
).await;
for lease_notification in lease_notifications {
use crate::proto::framing::encode_frame;
let notification_bytes = lease_notification.write_to_bytes();
let mut frame = Vec::with_capacity(notification_bytes.len() + 4);
encode_frame(&notification_bytes, &mut frame);
if let Some(tx) = conn.notification_tx.read().await.as_ref() {
let _ = tx.send(frame).await;
}
}
let result = {
let open = open_arc.read().await;
match open.handle.as_ref() {