From: Volker Lendecke Date: Tue, 14 Jun 2016 13:03:35 +0000 (+0200) Subject: smbd: Remove "listel" from notify_msg X-Git-Tag: tdb-1.3.10~320 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=16a1418f3aa08b1fd5c971481592bfddc250abf0;p=thirdparty%2Fsamba.git smbd: Remove "listel" from notify_msg We have all information that was kept in "notify_list" in other parts of smbd as well. The only possible downside of this patch is that we possibly have a lot more fsp's than fsp's with notifies, so notify_callback() might be a bit slower in this situation. If this turns out to be a problem, I'd rather put some more smarts into the notifyd protocol to enable a better indexed notify_callback(). For now, this avoids data to be kept in two places. Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/source3/smbd/notify_msg.c b/source3/smbd/notify_msg.c index cd9a0fb1e92..1379fc4aa6b 100644 --- a/source3/smbd/notify_msg.c +++ b/source3/smbd/notify_msg.c @@ -30,15 +30,9 @@ #include "lib/util/server_id_db.h" #include "smbd/notifyd/notifyd.h" -struct notify_list { - struct notify_list *next, *prev; - void *private_data; -}; - struct notify_context { struct server_id notifyd; struct messaging_context *msg_ctx; - struct notify_list *list; struct smbd_server_connection *sconn; void (*callback)(struct smbd_server_connection *sconn, @@ -67,7 +61,6 @@ struct notify_context *notify_init( return NULL; } ctx->msg_ctx = msg; - ctx->list = NULL; ctx->sconn = sconn; ctx->callback = callback; @@ -102,7 +95,6 @@ static void notify_handler(struct messaging_context *msg, void *private_data, private_data, struct notify_context); struct notify_event_msg *event_msg; struct notify_event event; - struct notify_list *listel; if (data->length < offsetof(struct notify_event_msg, path) + 1) { DEBUG(1, ("message too short: %u\n", (unsigned)data->length)); @@ -123,20 +115,13 @@ static void notify_handler(struct messaging_context *msg, void *private_data, "path=%s\n", __func__, (unsigned)event.action, event.private_data, event.path)); - for (listel = ctx->list; listel != NULL; listel = listel->next) { - if (listel->private_data == event.private_data) { - ctx->callback(ctx->sconn, listel->private_data, - event_msg->when, &event); - break; - } - } + ctx->callback(ctx->sconn, event.private_data, event_msg->when, &event); } NTSTATUS notify_add(struct notify_context *ctx, const char *path, uint32_t filter, uint32_t subdir_filter, void *private_data) { - struct notify_list *listel; struct notify_rec_change_msg msg = {}; struct iovec iov[2]; size_t pathlen; @@ -152,12 +137,6 @@ NTSTATUS notify_add(struct notify_context *ctx, pathlen = strlen(path)+1; - listel = (struct notify_list *)talloc(ctx, struct notify_list); - if (listel == NULL) { - return NT_STATUS_NO_MEMORY; - } - listel->private_data = private_data; - clock_gettime_mono(&msg.instance.creation_time); msg.instance.filter = filter; msg.instance.subdir_filter = subdir_filter; @@ -173,20 +152,17 @@ NTSTATUS notify_add(struct notify_context *ctx, iov, ARRAY_SIZE(iov), NULL, 0); if (!NT_STATUS_IS_OK(status)) { - TALLOC_FREE(listel); DEBUG(10, ("messaging_send_iov returned %s\n", nt_errstr(status))); return status; } - DLIST_ADD(ctx->list, listel); return NT_STATUS_OK; } NTSTATUS notify_remove(struct notify_context *ctx, void *private_data, char *path) { - struct notify_list *listel; struct notify_rec_change_msg msg = {}; struct iovec iov[2]; NTSTATUS status; @@ -196,17 +172,6 @@ NTSTATUS notify_remove(struct notify_context *ctx, void *private_data, return NT_STATUS_NOT_IMPLEMENTED; } - for (listel = ctx->list; listel != NULL; listel = listel->next) { - if (listel->private_data == private_data) { - DLIST_REMOVE(ctx->list, listel); - break; - } - } - if (listel == NULL) { - DEBUG(10, ("%p not found\n", private_data)); - return NT_STATUS_NOT_FOUND; - } - msg.instance.private_data = private_data; iov[0].iov_base = &msg; @@ -218,7 +183,6 @@ NTSTATUS notify_remove(struct notify_context *ctx, void *private_data, ctx->msg_ctx, ctx->notifyd, MSG_SMB_NOTIFY_REC_CHANGE, iov, ARRAY_SIZE(iov), NULL, 0); - TALLOC_FREE(listel); return status; }