ATTACH_DB: simplify the code slightly and change the semantics to only
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Thu, 24 Feb 2011 23:33:12 +0000 (10:33 +1100)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Thu, 24 Feb 2011 23:43:22 +0000 (10:43 +1100)
refuse a db attach during recovery IF we can associate the request from a
genuine real client instead of deciding this on whether client_id is zero or

This will suppress/avoid messages like these :
DB Attach to database %s refused. Can not match clientid...

server/ctdb_ltdb_server.c

index 07fdec0d4459b3434ff6da4e8c313138550f4ba0..19a68ec745e08f92b2c9b52803a9655a340fe1a6 100644 (file)
@@ -805,6 +805,7 @@ int32_t ctdb_control_db_attach(struct ctdb_context *ctdb, TDB_DATA indata,
        const char *db_name = (const char *)indata.dptr;
        struct ctdb_db_context *db;
        struct ctdb_node *node = ctdb->nodes[ctdb->pnn];
+       struct ctdb_client *client = NULL;
 
        /* dont allow any local clients to attach while we are in recovery mode
         * except for the recovery daemon.
@@ -812,13 +813,9 @@ int32_t ctdb_control_db_attach(struct ctdb_context *ctdb, TDB_DATA indata,
         * recovery daemons.
         */
        if (client_id != 0) {
-               struct ctdb_client *client = ctdb_reqid_find(ctdb, client_id, struct ctdb_client);
-
-               if (client == NULL) {
-                       DEBUG(DEBUG_ERR,("DB Attach to database %s refused. Can not match clientid:%d to a client structure.\n", db_name, client_id));
-                       return -1;
-               }
-
+               client = ctdb_reqid_find(ctdb, client_id, struct ctdb_client);
+       }
+       if (client != NULL) {
                /* If the node is inactive it is not part of the cluster
                   and we should not allow clients to attach to any
                   databases