Add READ handler oplock break (Phase 5.5)
Some checks failed
Test / test (push) Has been cancelled
Test / build (push) Has been cancelled

- Trigger oplock break before read if conflicting opens exist
- Use granted_access from Open struct
- Send notifications via notification_tx channel
- Fix WRITE handler granted_access source (from Tree)

All 229 tests pass.
This commit is contained in:
Warren
2026-06-21 01:13:35 +08:00
parent 2dd50e4cb6
commit 063a697e83
2 changed files with 34 additions and 2 deletions

View File

@@ -12,7 +12,7 @@ use crate::ntstatus;
use crate::server::ServerState; use crate::server::ServerState;
pub async fn handle( pub async fn handle(
_server: &Arc<ServerState>, server: &Arc<ServerState>,
conn: &Arc<Connection>, conn: &Arc<Connection>,
hdr: &Smb2Header, hdr: &Smb2Header,
body: &[u8], body: &[u8],
@@ -33,6 +33,32 @@ pub async fn handle(
Some(o) => o, Some(o) => o,
None => return HandlerResponse::err(ntstatus::STATUS_FILE_CLOSED), None => return HandlerResponse::err(ntstatus::STATUS_FILE_CLOSED),
}; };
// Phase 5.5: Get path and trigger oplock break before read (if needed)
let (path, share_access, granted_access) = {
let open = open_arc.read().await;
(open.last_path.clone(), open.share_access, open.granted_access)
};
// Trigger oplock break if this read conflicts with other opens
let notifications = server.oplock_manager.break_oplock(
&path,
share_access,
granted_access,
).await;
// Send notifications to affected clients
for notification in notifications {
use crate::proto::framing::encode_frame;
let notification_bytes = 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 result = {
let open = open_arc.read().await; let open = open_arc.read().await;
match open.handle.as_ref() { match open.handle.as_ref() {

View File

@@ -48,11 +48,17 @@ pub async fn handle(
(open.last_path.clone(), open.share_access) (open.last_path.clone(), open.share_access)
}; };
// Get granted_access from tree
let granted_access = {
let tree = tree_arc.read().await;
tree.granted_access
};
// Trigger oplock break for conflicting clients // Trigger oplock break for conflicting clients
let notifications = server.oplock_manager.break_oplock( let notifications = server.oplock_manager.break_oplock(
&path, &path,
share_access, share_access,
granted, granted_access,
).await; ).await;
// Send notifications to affected clients // Send notifications to affected clients