summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2016-06-14 11:55:13 +0200
committerJeremy Allison <jra@samba.org>2016-07-20 05:21:07 +0200
commitd446e406db3745ef2b217f31f2f8abd0254e7f03 (patch)
tree8ea24977ae4451f6d0167ee9bd714a4c84c84530 /source3
parent2779cae82311c5a9352b757580abfe336e2a551b (diff)
downloadsamba-d446e406db3745ef2b217f31f2f8abd0254e7f03.tar.gz
smbd: There's only one notify_callback
We do not have different callbacks per notify, put the callback function into the notify context Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3')
-rw-r--r--source3/smbd/notify.c3
-rw-r--r--source3/smbd/notify_msg.c35
-rw-r--r--source3/smbd/proto.h12
-rw-r--r--source3/smbd/service.c3
-rw-r--r--source3/utils/status.c2
5 files changed, 29 insertions, 26 deletions
diff --git a/source3/smbd/notify.c b/source3/smbd/notify.c
index c824ced5368..f493f11aa69 100644
--- a/source3/smbd/notify.c
+++ b/source3/smbd/notify.c
@@ -280,8 +280,7 @@ NTSTATUS change_notify_create(struct files_struct *fsp, uint32_t filter,
if ((filter != 0) || (subdir_filter != 0)) {
status = notify_add(fsp->conn->sconn->notify_ctx,
- fullpath, filter, subdir_filter,
- notify_callback, fsp);
+ fullpath, filter, subdir_filter, fsp);
}
return status;
diff --git a/source3/smbd/notify_msg.c b/source3/smbd/notify_msg.c
index 817bc79a2f8..e9f91995a11 100644
--- a/source3/smbd/notify_msg.c
+++ b/source3/smbd/notify_msg.c
@@ -32,8 +32,6 @@
struct notify_list {
struct notify_list *next, *prev;
- void (*callback)(void *private_data, struct timespec when,
- const struct notify_event *ctx);
void *private_data;
};
@@ -41,15 +39,19 @@ struct notify_context {
struct server_id notifyd;
struct messaging_context *msg_ctx;
struct notify_list *list;
+ void (*callback)(void *private_data, struct timespec when,
+ const struct notify_event *ctx);
};
static void notify_handler(struct messaging_context *msg, void *private_data,
uint32_t msg_type, struct server_id src,
DATA_BLOB *data);
-struct notify_context *notify_init(TALLOC_CTX *mem_ctx,
- struct messaging_context *msg,
- struct tevent_context *ev)
+struct notify_context *notify_init(
+ TALLOC_CTX *mem_ctx, struct messaging_context *msg,
+ struct tevent_context *ev,
+ void (*callback)(void *, struct timespec,
+ const struct notify_event *))
{
struct server_id_db *names_db;
struct notify_context *ctx;
@@ -61,6 +63,7 @@ struct notify_context *notify_init(TALLOC_CTX *mem_ctx,
}
ctx->msg_ctx = msg;
ctx->list = NULL;
+ ctx->callback = callback;
names_db = messaging_names_db(msg);
if (!server_id_db_lookup_one(names_db, "notify-daemon",
@@ -70,12 +73,15 @@ struct notify_context *notify_init(TALLOC_CTX *mem_ctx,
return NULL;
}
- status = messaging_register(msg, ctx, MSG_PVFS_NOTIFY, notify_handler);
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(1, ("messaging_register failed: %s\n",
- nt_errstr(status)));
- TALLOC_FREE(ctx);
- return NULL;
+ if (callback != NULL) {
+ status = messaging_register(msg, ctx, MSG_PVFS_NOTIFY,
+ notify_handler);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(1, ("messaging_register failed: %s\n",
+ nt_errstr(status)));
+ TALLOC_FREE(ctx);
+ return NULL;
+ }
}
return ctx;
@@ -112,8 +118,8 @@ static void notify_handler(struct messaging_context *msg, void *private_data,
for (listel = ctx->list; listel != NULL; listel = listel->next) {
if (listel->private_data == event.private_data) {
- listel->callback(listel->private_data, event_msg->when,
- &event);
+ ctx->callback(listel->private_data, event_msg->when,
+ &event);
break;
}
}
@@ -121,8 +127,6 @@ static void notify_handler(struct messaging_context *msg, void *private_data,
NTSTATUS notify_add(struct notify_context *ctx,
const char *path, uint32_t filter, uint32_t subdir_filter,
- void (*callback)(void *, struct timespec,
- const struct notify_event *),
void *private_data)
{
struct notify_list *listel;
@@ -145,7 +149,6 @@ NTSTATUS notify_add(struct notify_context *ctx,
if (listel == NULL) {
return NT_STATUS_NO_MEMORY;
}
- listel->callback = callback;
listel->private_data = private_data;
clock_gettime_mono(&msg.instance.creation_time);
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h
index f3b9e73b88f..b677748c2e6 100644
--- a/source3/smbd/proto.h
+++ b/source3/smbd/proto.h
@@ -583,13 +583,13 @@ int fam_watch(TALLOC_CTX *mem_ctx,
/* The following definitions come from smbd/notify_internal.c */
-struct notify_context *notify_init(TALLOC_CTX *mem_ctx,
- struct messaging_context *messaging_ctx,
- struct tevent_context *ev);
-NTSTATUS notify_add(struct notify_context *notify,
+struct notify_context *notify_init(
+ TALLOC_CTX *mem_ctx, struct messaging_context *msg,
+ struct tevent_context *ev,
+ void (*callback)(void *, struct timespec,
+ const struct notify_event *));
+NTSTATUS notify_add(struct notify_context *ctx,
const char *path, uint32_t filter, uint32_t subdir_filter,
- void (*callback)(void *, struct timespec,
- const struct notify_event *),
void *private_data);
NTSTATUS notify_remove(struct notify_context *ctx, void *private_data,
char *path);
diff --git a/source3/smbd/service.c b/source3/smbd/service.c
index 37440e01d5d..4b16dbad5e9 100644
--- a/source3/smbd/service.c
+++ b/source3/smbd/service.c
@@ -528,7 +528,8 @@ static NTSTATUS notify_init_sconn(struct smbd_server_connection *sconn)
return NT_STATUS_OK;
}
- sconn->notify_ctx = notify_init(sconn, sconn->msg_ctx, sconn->ev_ctx);
+ sconn->notify_ctx = notify_init(sconn, sconn->msg_ctx, sconn->ev_ctx,
+ notify_callback);
if (sconn->notify_ctx == NULL) {
return NT_STATUS_NO_MEMORY;
}
diff --git a/source3/utils/status.c b/source3/utils/status.c
index 9aefd5eb97f..7bff1023853 100644
--- a/source3/utils/status.c
+++ b/source3/utils/status.c
@@ -708,7 +708,7 @@ int main(int argc, const char *argv[])
struct notify_context *n;
n = notify_init(talloc_tos(), msg_ctx,
- messaging_tevent_context(msg_ctx));
+ messaging_tevent_context(msg_ctx), NULL);
if (n == NULL) {
goto done;
}