s3:smbcontrol: let smbd pass the idmap msg to its children for convenience
authorGregor Beck <gbeck@sernet.de>
Thu, 6 Oct 2011 13:26:32 +0000 (15:26 +0200)
committerMichael Adam <obnox@samba.org>
Wed, 12 Oct 2011 20:45:53 +0000 (22:45 +0200)
Signed-off-by: Michael Adam <obnox@samba.org>
source3/lib/id_cache.c
source3/lib/id_cache.h
source3/smbd/msg_idmap.c
source3/smbd/proto.h
source3/smbd/server.c

index e71934d6e3cb010f5c418b0195e92e878042b28c..23dcce1eb49c31fdbce9346a815f845ef99f6d02 100644 (file)
@@ -161,11 +161,11 @@ void id_cache_delete_from_cache(const struct id_cache_ref* id)
 }
 
 
-static void id_cache_flush(struct messaging_context *msg_ctx,
-                          void* private_data,
-                          uint32_t msg_type,
-                          struct server_id server_id,
-                          DATA_BLOB* data)
+void id_cache_flush_message(struct messaging_context *msg_ctx,
+                           void* private_data,
+                           uint32_t msg_type,
+                           struct server_id server_id,
+                           DATA_BLOB* data)
 {
        const char *msg = data ? (const char *)data->data : NULL;
 
@@ -181,11 +181,11 @@ static void id_cache_flush(struct messaging_context *msg_ctx,
        }
 }
 
-static void id_cache_delete(struct messaging_context *msg_ctx,
-                           void *private_data,
-                           uint32_t msg_type,
-                           struct server_id server_id,
-                           DATA_BLOB* data)
+void id_cache_delete_message(struct messaging_context *msg_ctx,
+                            void *private_data,
+                            uint32_t msg_type,
+                            struct server_id server_id,
+                            DATA_BLOB* data)
 {
        const char *msg = (data && data->data) ? (const char *)data->data : "<NULL>";
        struct id_cache_ref id;
@@ -200,6 +200,6 @@ static void id_cache_delete(struct messaging_context *msg_ctx,
 
 void id_cache_register_msgs(struct messaging_context *ctx)
 {
-       messaging_register(ctx, NULL, ID_CACHE_FLUSH,  id_cache_flush);
-       messaging_register(ctx, NULL, ID_CACHE_DELETE, id_cache_delete);
+       messaging_register(ctx, NULL, ID_CACHE_FLUSH,  id_cache_flush_message);
+       messaging_register(ctx, NULL, ID_CACHE_DELETE, id_cache_delete_message);
 }
index 00fd2853c9177514d17d4ce16c7f37e44dc22328..53731b55f5fe14401ae7ecc70d6ce191d75e2f05 100644 (file)
@@ -32,3 +32,15 @@ bool id_cache_ref_parse(const char* str, struct id_cache_ref* id);
 void id_cache_delete_from_cache(const struct id_cache_ref* id);
 
 void id_cache_register_msgs(struct messaging_context *ctx);
+
+void id_cache_delete_message(struct messaging_context *msg_ctx,
+                            void *private_data,
+                            uint32_t msg_type,
+                            struct server_id server_id,
+                            DATA_BLOB* data);
+
+void id_cache_flush_message(struct messaging_context *msg_ctx,
+                           void* private_data,
+                           uint32_t msg_type,
+                           struct server_id server_id,
+                           DATA_BLOB* data);
index cb8fbcd42ffe622d5035b42552f5fc1264dc92c7..757cac0e3f766e0e08ef6ab06d415720022a0b57 100644 (file)
@@ -129,13 +129,46 @@ static void id_cache_kill(struct messaging_context *msg_ctx,
                return;
        }
 
+       if (am_parent) {
+               messaging_send_to_children(msg_ctx, msg_type, data);
+       }
+
        if (id_in_use(validated_users, &id)) {
                exit_server_cleanly(msg);
        }
        id_cache_delete_from_cache(&id);
 }
 
-void id_cache_register_kill_msg(struct messaging_context *ctx)
+static void id_cache_flush(struct messaging_context *ctx,
+                          void* data,
+                          uint32_t msg_type,
+                          struct server_id srv_id,
+                          DATA_BLOB* msg_data)
+{
+       id_cache_flush_message(ctx, data, msg_type, srv_id, msg_data);
+
+       if (am_parent) {
+               messaging_send_to_children(ctx, msg_type, msg_data);
+       }
+}
+
+static void id_cache_delete(struct messaging_context *ctx,
+                           void* data,
+                           uint32_t msg_type,
+                           struct server_id srv_id,
+                           DATA_BLOB* msg_data)
+{
+       id_cache_delete_message(ctx, data, msg_type, srv_id, msg_data);
+
+       if (am_parent) {
+               messaging_send_to_children(ctx, msg_type, msg_data);
+       }
+}
+
+
+void msg_idmap_register_msg(struct messaging_context *ctx)
 {
+       messaging_register(ctx, NULL, ID_CACHE_FLUSH,  id_cache_flush);
+       messaging_register(ctx, NULL, ID_CACHE_DELETE, id_cache_delete);
        messaging_register(ctx, NULL, ID_CACHE_KILL, id_cache_kill);
 }
index 40281804ccf2152075cd39ca6a6d2dc15aa440ba..b3183d778dbbe6ccafdc794c0ab59fd77a1f3f6f 100644 (file)
@@ -1189,6 +1189,6 @@ void *avahi_start_register(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
 
 /* The following definitions come from smbd/msg_idmap.c */
 
-void id_cache_register_kill_msg(struct messaging_context *ctx);
+void msg_idmap_register_msg(struct messaging_context *ctx);
 
 #endif /* _SMBD_PROTO_H_ */
index 7771c8578491b60cb4da4e7636534265ff3d201f..e47187a6975bb0c43b8ea1adfe4c6acf9af03aef 100644 (file)
@@ -759,8 +759,7 @@ static bool open_sockets_smbd(struct smbd_parent_context *parent,
                           smb_pcap_updated);
        brl_register_msgs(msg_ctx);
 
-       id_cache_register_msgs(msg_ctx);
-       id_cache_register_kill_msg(msg_ctx);
+       msg_idmap_register_msg(msg_ctx);
 
 #ifdef CLUSTER_SUPPORT
        if (lp_clustering()) {