summaryrefslogtreecommitdiff
path: root/source3/smbd/notify.c
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2015-04-21 10:16:16 +0200
committerJeremy Allison <jra@samba.org>2015-04-22 23:00:20 +0200
commit50a1247927cb68303701a11517811deda10364f7 (patch)
treed05f819910481fe7223dd81ae0a1a9c79666b82d /source3/smbd/notify.c
parentb0d4a7daa149cfc9ef697dd7fae4524a35078126 (diff)
downloadsamba-50a1247927cb68303701a11517811deda10364f7.tar.gz
smbd: Cancel pending notifies if the directory goes away
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/smbd/notify.c')
-rw-r--r--source3/smbd/notify.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/source3/smbd/notify.c b/source3/smbd/notify.c
index 5ac8c0c791d..8cb44df3c1d 100644
--- a/source3/smbd/notify.c
+++ b/source3/smbd/notify.c
@@ -23,6 +23,7 @@
#include "smbd/smbd.h"
#include "smbd/globals.h"
#include "../librpc/gen_ndr/ndr_notify.h"
+#include "librpc/gen_ndr/ndr_file_id.h"
struct notify_change_event {
struct timespec when;
@@ -418,6 +419,48 @@ void smbd_notify_cancel_by_smbreq(const struct smb_request *smbreq)
change_notify_remove_request(sconn, map->req);
}
+static struct files_struct *smbd_notify_cancel_deleted_fn(
+ struct files_struct *fsp, void *private_data)
+{
+ struct file_id *fid = talloc_get_type_abort(
+ private_data, struct file_id);
+
+ if (file_id_equal(&fsp->file_id, fid)) {
+ remove_pending_change_notify_requests_by_fid(
+ fsp, NT_STATUS_DELETE_PENDING);
+ }
+ return NULL;
+}
+
+void smbd_notify_cancel_deleted(struct messaging_context *msg,
+ void *private_data, uint32_t msg_type,
+ struct server_id server_id, DATA_BLOB *data)
+{
+ struct smbd_server_connection *sconn = talloc_get_type_abort(
+ private_data, struct smbd_server_connection);
+ struct file_id *fid;
+ enum ndr_err_code ndr_err;
+
+ fid = talloc(talloc_tos(), struct file_id);
+ if (fid == NULL) {
+ DEBUG(1, ("talloc failed\n"));
+ return;
+ }
+
+ ndr_err = ndr_pull_struct_blob_all(
+ data, fid, fid, (ndr_pull_flags_fn_t)ndr_pull_file_id);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ DEBUG(10, ("%s: ndr_pull_file_id failed: %s\n", __func__,
+ ndr_errstr(ndr_err)));
+ goto done;
+ }
+
+ files_forall(sconn, smbd_notify_cancel_deleted_fn, fid);
+
+done:
+ TALLOC_FREE(fid);
+}
+
/****************************************************************************
Delete entries by fnum from the change notify pending queue.
*****************************************************************************/