ctdbd: Create a utility function to log error for "not implemented" controls
authorAmitay Isaacs <amitay@gmail.com>
Thu, 12 Sep 2013 06:36:09 +0000 (16:36 +1000)
committerAmitay Isaacs <amitay@gmail.com>
Fri, 4 Oct 2013 05:20:25 +0000 (15:20 +1000)
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
(This used to be ctdb commit 3c892ea1b5aa42686adb82ce29b9fcfdf9d204a1)

ctdb/server/ctdb_control.c

index cd96e822b597f6464666701235358e27666b3da1..4885e5f7be85070854324b6316d62eed342cc31f 100644 (file)
@@ -65,6 +65,20 @@ int32_t ctdb_dump_memory(struct ctdb_context *ctdb, TDB_DATA *outdata)
        return 0;
 }
 
+static int32_t control_not_implemented(const char *unsupported,
+                                      const char *alternate)
+{
+       if (alternate == NULL) {
+               DEBUG(DEBUG_ERR,
+                     ("Control %s is not implemented any more\n",
+                      unsupported));
+       } else {
+               DEBUG(DEBUG_ERR,
+                     ("Control %s is not implemented any more, use %s instead\n",
+                      unsupported, alternate));
+       }
+       return -1;
+}
 
 /*
   process a control request
@@ -172,10 +186,7 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
                return ctdb_control_pull_db(ctdb, indata, outdata);
 
        case CTDB_CONTROL_SET_DMASTER: 
-               CHECK_CONTROL_DATA_SIZE(sizeof(struct ctdb_control_set_dmaster));
-               DEBUG(DEBUG_ERR, ("The SET_DMASTER control is not implemented "
-                                 "any more.\n"));
-               return  -1;
+               return control_not_implemented("SET_DMASTER", NULL);
 
        case CTDB_CONTROL_PUSH_DB:
                return ctdb_control_push_db(ctdb, indata);