winbindd: add and use idmap_child_pid()
authorStefan Metzmacher <metze@samba.org>
Fri, 11 Sep 2020 12:06:04 +0000 (14:06 +0200)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 23 Oct 2020 03:25:35 +0000 (03:25 +0000)
We should avoid calling idmap_child() as much as possible.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14539

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
source3/winbindd/winbindd_cm.c
source3/winbindd/winbindd_dual.c
source3/winbindd/winbindd_idmap.c
source3/winbindd/winbindd_proto.h

index 344eac2804b1e532a9e79765e473153eae4a76c3..e7399434536e892fd41c51464a361abb59128e45 100644 (file)
@@ -464,11 +464,11 @@ void set_domain_offline(struct winbindd_domain *domain)
           primary domain goes offline */
 
        if ( domain->primary ) {
-               struct winbindd_child *idmap = idmap_child();
+               pid_t idmap_pid = idmap_child_pid();
 
-               if ( idmap->pid != 0 ) {
+               if (idmap_pid != 0) {
                        messaging_send_buf(global_messaging_context(),
-                                          pid_to_procid(idmap->pid), 
+                                          pid_to_procid(idmap_pid),
                                           MSG_WINBIND_OFFLINE, 
                                           (const uint8_t *)domain->name,
                                           strlen(domain->name)+1);
@@ -550,11 +550,11 @@ static void set_domain_online(struct winbindd_domain *domain)
           primary domain comes online */
 
        if ( domain->primary ) {
-               struct winbindd_child *idmap = idmap_child();
+               pid_t idmap_pid = idmap_child_pid();
 
-               if ( idmap->pid != 0 ) {
+               if (idmap_pid != 0) {
                        messaging_send_buf(global_messaging_context(),
-                                          pid_to_procid(idmap->pid), 
+                                          pid_to_procid(idmap_pid),
                                           MSG_WINBIND_ONLINE, 
                                           (const uint8_t *)domain->name,
                                           strlen(domain->name)+1);
index 0187d232640371e11560d2100186d8189fbc9083..ba3f79efa8c73cc6d09ddc69f488cb5de01e9b31 100644 (file)
@@ -1039,11 +1039,11 @@ void winbind_msg_online(struct messaging_context *msg_ctx,
                   primary domain comes back online */
 
                if ( domain->primary ) {
-                       struct winbindd_child *idmap = idmap_child();
+                       pid_t idmap_pid = idmap_child_pid();
 
-                       if ( idmap->pid != 0 ) {
+                       if (idmap_pid != 0) {
                                messaging_send_buf(msg_ctx,
-                                                  pid_to_procid(idmap->pid), 
+                                                  pid_to_procid(idmap_pid),
                                                   MSG_WINBIND_ONLINE,
                                                   (const uint8_t *)domain->name,
                                                   strlen(domain->name)+1);
index 2ee436bc7dcd28794da2b135b32e44195dec59ee..965a7839f17d1b3400ff1df25935d44f466d06ba 100644 (file)
@@ -34,6 +34,11 @@ struct winbindd_child *idmap_child(void)
        return &static_idmap_child;
 }
 
+pid_t idmap_child_pid(void)
+{
+       return static_idmap_child.pid;
+}
+
 struct dcerpc_binding_handle *idmap_child_handle(void)
 {
        return static_idmap_child.binding_handle;
index 2a829b0171a39228c96cee683670a35a8ca7e30b..0476dd529982d297c5e8eb7473320fc4db5f3794 100644 (file)
@@ -359,6 +359,7 @@ NTSTATUS winbindd_print_groupmembers(struct db_context *members,
 
 void init_idmap_child(void);
 struct winbindd_child *idmap_child(void);
+pid_t idmap_child_pid(void);
 struct dcerpc_binding_handle *idmap_child_handle(void);
 struct idmap_domain *idmap_find_domain_with_sid(const char *domname,
                                                const struct dom_sid *sid);