return NULL;
}
+struct share_mode_entry *find_share_mode_entry_durable(
+ struct share_mode_lock *lck, uint64_t persistent_fid)
+{
+ struct share_mode_data *d = lck->data;
+ uint32_t i;
+
+ for (i=0; i<d->num_share_modes; i++) {
+ struct share_mode_entry *e = &d->share_modes[i];
+
+ if (!server_id_is_disconnected(&e->pid)) {
+ continue;
+ }
+ if (!is_valid_share_mode_entry(e)) {
+ continue;
+ }
+ if (persistent_fid != e->share_file_id) {
+ continue;
+ }
+ return e;
+ }
+ return NULL;
+}
+
/*******************************************************************
Del the share mode of a file for this process. Return the number of
entries left.
{
struct share_mode_entry *e;
- if (lck->data->num_share_modes != 1) {
- return false;
- }
-
if (fsp->op == NULL) {
return false;
}
uint32_t lease_idx);
struct share_mode_entry *find_share_mode_entry(struct share_mode_lock *lck,
files_struct *fsp);
+struct share_mode_entry *find_share_mode_entry_durable(
+ struct share_mode_lock *lck, uint64_t persistent_fid);
void remove_stale_share_mode_entries(struct share_mode_data *d);
bool del_share_mode(struct share_mode_lock *lck, files_struct *fsp);
bool mark_share_mode_disconnected(struct share_mode_lock *lck,
return NT_STATUS_INTERNAL_DB_ERROR;
}
- if (lck->data->num_share_modes > 1) {
- /*
- * It can't be durable if there is more than one handle
- * on the file.
- */
- DEBUG(5, ("vfs_default_durable_reconnect: more than one "
- "share-mode entry - can not be durable\n"));
- TALLOC_FREE(lck);
- return NT_STATUS_OBJECT_NAME_NOT_FOUND;
- }
-
- e = &lck->data->share_modes[0];
-
- if (!server_id_is_disconnected(&e->pid)) {
- DEBUG(5, ("vfs_default_durable_reconnect: denying durable "
- "reconnect for handle that was not marked "
- "disconnected (e.g. smbd or cluster node died)\n"));
- TALLOC_FREE(lck);
- return NT_STATUS_OBJECT_NAME_NOT_FOUND;
- }
-
- if (e->share_file_id != op->global->open_persistent_id) {
+ e = find_share_mode_entry_durable(lck, op->global->open_persistent_id);
+ if (e == NULL) {
DEBUG(5, ("vfs_default_durable_reconnect: denying durable "
- "share_file_id changed %llu != %llu"
- "(e.g. another client had opened the file)\n",
- (unsigned long long)e->share_file_id,
- (unsigned long long)op->global->open_persistent_id));
+ "reconnect for handle - share mode not found\n"));
TALLOC_FREE(lck);
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
}