s3: Remove serverid_[de]register_self
authorVolker Lendecke <vl@samba.org>
Sun, 4 Jul 2010 14:08:03 +0000 (16:08 +0200)
committerVolker Lendecke <vl@samba.org>
Sun, 4 Jul 2010 14:41:14 +0000 (16:41 +0200)
This removes some deep references to procid_self()

source3/include/serverid.h
source3/lib/serverid.c
source3/nmbd/nmbd.c
source3/printing/printing.c
source3/smbd/negprot.c
source3/smbd/server.c
source3/smbd/server_exit.c
source3/winbindd/winbindd.c

index e60fc47afea9b612ae064205e5bdb69cd199c22d..db2ce5ab87555c45fac9488d7844ae62652bbfac 100644 (file)
 /*
  * Register a server with its unique id
  */
-bool serverid_register(const struct server_id *id, uint32_t msg_flags);
-
-/*
- * Register ourselves with a unique id
- */
-bool serverid_register_self(uint32_t msg_flags);
+bool serverid_register(const struct server_id id, uint32_t msg_flags);
 
 /*
  * De-register a server with its unique id
  */
-bool serverid_deregister(const struct server_id *id);
-
-/*
- * De-register ourself
- */
-bool serverid_deregister_self(void);
+bool serverid_deregister(const struct server_id id);
 
 /*
  * Check existence of a server id
index dc4834b8dadcc9d506c53cf6a9dc981618bc77c2..f92c8cfd58d8eb0fd72ead0ec0d3bcf6a91f2dbe 100644 (file)
@@ -76,7 +76,7 @@ static void serverid_fill_key(const struct server_id *id,
 #endif
 }
 
-bool serverid_register(const struct server_id *id, uint32_t msg_flags)
+bool serverid_register(const struct server_id id, uint32_t msg_flags)
 {
        struct db_context *db;
        struct serverid_key key;
@@ -91,7 +91,7 @@ bool serverid_register(const struct server_id *id, uint32_t msg_flags)
                return false;
        }
 
-       serverid_fill_key(id, &key);
+       serverid_fill_key(&id, &key);
        tdbkey = make_tdb_data((uint8_t *)&key, sizeof(key));
 
        rec = db->fetch_locked(db, talloc_tos(), tdbkey);
@@ -101,7 +101,7 @@ bool serverid_register(const struct server_id *id, uint32_t msg_flags)
        }
 
        ZERO_STRUCT(data);
-       data.unique_id = id->unique_id;
+       data.unique_id = id.unique_id;
        data.msg_flags = msg_flags;
 
        tdbdata = make_tdb_data((uint8_t *)&data, sizeof(data));
@@ -117,15 +117,7 @@ done:
        return ret;
 }
 
-bool serverid_register_self(uint32_t msg_flags)
-{
-       struct server_id pid;
-
-       pid = procid_self();
-       return serverid_register(&pid, msg_flags);
-}
-
-bool serverid_deregister(const struct server_id *id)
+bool serverid_deregister(struct server_id id)
 {
        struct db_context *db;
        struct serverid_key key;
@@ -139,7 +131,7 @@ bool serverid_deregister(const struct server_id *id)
                return false;
        }
 
-       serverid_fill_key(id, &key);
+       serverid_fill_key(&id, &key);
        tdbkey = make_tdb_data((uint8_t *)&key, sizeof(key));
 
        rec = db->fetch_locked(db, talloc_tos(), tdbkey);
@@ -160,14 +152,6 @@ done:
        return ret;
 }
 
-bool serverid_deregister_self(void)
-{
-       struct server_id pid;
-
-       pid = procid_self();
-       return serverid_deregister(&pid);
-}
-
 struct serverid_exists_state {
        const struct server_id *id;
        bool exists;
index fa106a9499c505eb3860b2ee15c1e75fca5f0308..f211d6c67129323af6f6f07648daa46514f502fa 100644 (file)
@@ -84,7 +84,7 @@ static void terminate(void)
        kill_async_dns_child();
 
        gencache_stabilize();
-       serverid_deregister_self();
+       serverid_deregister(procid_self());
 
        pidfile_unlink();
 
@@ -933,7 +933,8 @@ static bool open_sockets(bool isdaemon, int port)
 
        /* get broadcast messages */
 
-       if (!serverid_register_self(FLAG_MSG_GENERAL|FLAG_MSG_DBWRAP)) {
+       if (!serverid_register(procid_self(),
+                              FLAG_MSG_GENERAL|FLAG_MSG_DBWRAP)) {
                DEBUG(1, ("Could not register myself in serverid.tdb\n"));
                exit(1);
        }
index 6bf037a81705be3218641496aefb2d5f9085b81e..b69350496af125310bd78bb98599f6b71d55ecc1 100644 (file)
@@ -1446,8 +1446,9 @@ void start_background_queue(void)
                smbd_setup_sig_term_handler();
                smbd_setup_sig_hup_handler();
 
-               if (!serverid_register_self(FLAG_MSG_GENERAL|FLAG_MSG_SMBD
-                                           |FLAG_MSG_PRINT_GENERAL)) {
+               if (!serverid_register(procid_self(),
+                                      FLAG_MSG_GENERAL|FLAG_MSG_SMBD
+                                      |FLAG_MSG_PRINT_GENERAL)) {
                        exit(1);
                }
 
index 0a928a23d61cbfca0c3333afff0ba79f2c6b3857..e6fc23adee21c7ff86400863fe1b24b2373018e8 100644 (file)
@@ -665,8 +665,9 @@ void reply_negprot(struct smb_request *req)
           when the client connects to port 445.  Of course there is a small
           window where we are listening to messages   -- jerry */
 
-       serverid_register_self(FLAG_MSG_GENERAL|FLAG_MSG_SMBD
-                              |FLAG_MSG_PRINT_GENERAL);
+       serverid_register(procid_self(),
+                         FLAG_MSG_GENERAL|FLAG_MSG_SMBD
+                         |FLAG_MSG_PRINT_GENERAL);
     
        /* Check for protocols, most desirable first */
        for (protocol = 0; supported_protocols[protocol].proto_name; protocol++) {
index 1b00f2ca4e5ad4adb368608f1a1f72b96034e3dc..65db77c0b95db94361d5f9fae30cb7e6b001067f 100644 (file)
@@ -242,7 +242,7 @@ static void remove_child_pid(pid_t pid, bool unclean_shutdown)
        child_id = procid_self(); /* Just initialize pid and potentially vnn */
        child_id.pid = pid;
 
-       if (!serverid_deregister(&child_id)) {
+       if (!serverid_deregister(child_id)) {
                DEBUG(1, ("Could not remove pid %d from serverid.tdb\n",
                          (int)pid));
        }
@@ -424,9 +424,10 @@ static void smbd_accept_connection(struct tevent_context *ev,
                smbd_setup_sig_term_handler();
                smbd_setup_sig_hup_handler();
 
-               if (!serverid_register_self(FLAG_MSG_GENERAL|FLAG_MSG_SMBD
-                                           |FLAG_MSG_DBWRAP
-                                           |FLAG_MSG_PRINT_GENERAL)) {
+               if (!serverid_register(procid_self(),
+                                      FLAG_MSG_GENERAL|FLAG_MSG_SMBD
+                                      |FLAG_MSG_DBWRAP
+                                      |FLAG_MSG_PRINT_GENERAL)) {
                        exit_server_cleanly("Could not register myself in "
                                            "serverid.tdb");
                }
@@ -662,8 +663,9 @@ static bool open_sockets_smbd(struct smbd_parent_context *parent,
           operations until it has gone thru a full startup, which
           includes checking to see that smbd is listening. */
 
-       if (!serverid_register_self(FLAG_MSG_GENERAL|FLAG_MSG_SMBD
-                                   |FLAG_MSG_DBWRAP)) {
+       if (!serverid_register(procid_self(),
+                              FLAG_MSG_GENERAL|FLAG_MSG_SMBD
+                              |FLAG_MSG_DBWRAP)) {
                DEBUG(0, ("open_sockets_smbd: Failed to register "
                          "myself in serverid.tdb\n"));
                return false;
index b69eb4aab39204e631850e9b16ca5aabeb29d10b..6c46a522d43148d5fe3a4cc0c454236c71e3d2fa 100644 (file)
@@ -97,7 +97,7 @@ static void exit_server_common(enum server_exit_reason how,
                /*
                 * For children the parent takes care of cleaning up
                 */
-               serverid_deregister_self();
+               serverid_deregister(procid_self());
        }
 
 #ifdef WITH_DFS
index 87a8be64c919bc69a2758f08154a9bb5bf7c61d4..34fd271194c97303f48ec5c76b49782c8459f9ce 100644 (file)
@@ -176,7 +176,7 @@ static void terminate(bool is_parent)
 #endif
 
        if (is_parent) {
-               serverid_deregister_self();
+               serverid_deregister(procid_self());
                pidfile_unlink();
        }
 
@@ -1031,7 +1031,8 @@ void winbindd_register_handlers(void)
 
        /* get broadcast messages */
 
-       if (!serverid_register_self(FLAG_MSG_GENERAL|FLAG_MSG_DBWRAP)) {
+       if (!serverid_register(procid_self(),
+                              FLAG_MSG_GENERAL|FLAG_MSG_DBWRAP)) {
                DEBUG(1, ("Could not register myself in serverid.tdb\n"));
                exit(1);
        }