Add READ handler oplock break (Phase 5.5)
- 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:
28
vendor/smb-server/src/handlers/read.rs
vendored
28
vendor/smb-server/src/handlers/read.rs
vendored
@@ -12,7 +12,7 @@ use crate::ntstatus;
|
||||
use crate::server::ServerState;
|
||||
|
||||
pub async fn handle(
|
||||
_server: &Arc<ServerState>,
|
||||
server: &Arc<ServerState>,
|
||||
conn: &Arc<Connection>,
|
||||
hdr: &Smb2Header,
|
||||
body: &[u8],
|
||||
@@ -33,6 +33,32 @@ pub async fn handle(
|
||||
Some(o) => o,
|
||||
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(¬ification_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() {
|
||||
|
||||
8
vendor/smb-server/src/handlers/write.rs
vendored
8
vendor/smb-server/src/handlers/write.rs
vendored
@@ -48,11 +48,17 @@ pub async fn handle(
|
||||
(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
|
||||
let notifications = server.oplock_manager.break_oplock(
|
||||
&path,
|
||||
share_access,
|
||||
granted,
|
||||
granted_access,
|
||||
).await;
|
||||
|
||||
// Send notifications to affected clients
|
||||
|
||||
Reference in New Issue
Block a user