lib: Make ctdbd_control_local return 0/errno
authorVolker Lendecke <vl@samba.org>
Sat, 3 Oct 2015 03:42:05 +0000 (20:42 -0700)
committerJeremy Allison <jra@samba.org>
Wed, 7 Oct 2015 21:54:06 +0000 (23:54 +0200)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/include/ctdbd_conn.h
source3/lib/ctdbd_conn.c
source3/lib/dbwrap/dbwrap_ctdb.c

index ff1bc95c20b029a1ef6ae34a11f1608866520007..7073c0c8e20080fa927cd3506e4e16af682d6e59 100644 (file)
@@ -76,10 +76,10 @@ int ctdbd_register_ips(struct ctdbd_connection *conn,
                                 void *private_data),
                       void *private_data);
 
-NTSTATUS ctdbd_control_local(struct ctdbd_connection *conn, uint32_t opcode,
-                            uint64_t srvid, uint32_t flags, TDB_DATA data,
-                            TALLOC_CTX *mem_ctx, TDB_DATA *outdata,
-                            int *cstatus);
+int ctdbd_control_local(struct ctdbd_connection *conn, uint32_t opcode,
+                       uint64_t srvid, uint32_t flags, TDB_DATA data,
+                       TALLOC_CTX *mem_ctx, TDB_DATA *outdata,
+                       int *cstatus);
 NTSTATUS ctdb_watch_us(struct ctdbd_connection *conn);
 NTSTATUS ctdb_unwatch(struct ctdbd_connection *conn);
 
index 0ba0d7505fd16bf6f91c562cc40a035eb69b814a..3d9f8f01b27209d0a7e48eef6eae7159993ee22e 100644 (file)
@@ -1243,26 +1243,20 @@ int ctdbd_register_ips(struct ctdbd_connection *conn,
 /*
   call a control on the local node
  */
-NTSTATUS ctdbd_control_local(struct ctdbd_connection *conn, uint32_t opcode,
-                            uint64_t srvid, uint32_t flags, TDB_DATA data,
-                            TALLOC_CTX *mem_ctx, TDB_DATA *outdata,
-                            int *cstatus)
+int ctdbd_control_local(struct ctdbd_connection *conn, uint32_t opcode,
+                       uint64_t srvid, uint32_t flags, TDB_DATA data,
+                       TALLOC_CTX *mem_ctx, TDB_DATA *outdata,
+                       int *cstatus)
 {
-       int ret;
-
-       ret = ctdbd_control(conn, CTDB_CURRENT_NODE, opcode, srvid, flags, data,
-                           mem_ctx, outdata, cstatus);
-       if (ret != 0) {
-               return map_nt_error_from_unix(ret);
-       }
-       return NT_STATUS_OK;
+       return ctdbd_control(conn, CTDB_CURRENT_NODE, opcode, srvid, flags, data,
+                            mem_ctx, outdata, cstatus);
 }
 
 NTSTATUS ctdb_watch_us(struct ctdbd_connection *conn)
 {
        struct ctdb_client_notify_register reg_data;
        size_t struct_len;
-       NTSTATUS status;
+       int ret;
        int cstatus;
 
        reg_data.srvid = CTDB_SRVID_SAMBA_NOTIFY;
@@ -1272,34 +1266,36 @@ NTSTATUS ctdb_watch_us(struct ctdbd_connection *conn)
        struct_len = offsetof(struct ctdb_client_notify_register,
                              notify_data) + reg_data.len;
 
-       status = ctdbd_control_local(
+       ret = ctdbd_control_local(
                conn, CTDB_CONTROL_REGISTER_NOTIFY, conn->rand_srvid, 0,
                make_tdb_data((uint8_t *)&reg_data, struct_len),
                NULL, NULL, &cstatus);
-       if (!NT_STATUS_IS_OK(status)) {
+       if (ret != 0) {
                DEBUG(1, ("ctdbd_control_local failed: %s\n",
-                         nt_errstr(status)));
+                         strerror(ret)));
+               return map_nt_error_from_unix(ret);
        }
-       return status;
+       return NT_STATUS_OK;
 }
 
 NTSTATUS ctdb_unwatch(struct ctdbd_connection *conn)
 {
        struct ctdb_client_notify_deregister dereg_data;
-       NTSTATUS status;
+       int ret;
        int cstatus;
 
        dereg_data.srvid = CTDB_SRVID_SAMBA_NOTIFY;
 
-       status = ctdbd_control_local(
+       ret = ctdbd_control_local(
                conn, CTDB_CONTROL_DEREGISTER_NOTIFY, conn->rand_srvid, 0,
                make_tdb_data((uint8_t *)&dereg_data, sizeof(dereg_data)),
                NULL, NULL, &cstatus);
-       if (!NT_STATUS_IS_OK(status)) {
+       if (ret != 0) {
                DEBUG(1, ("ctdbd_control_local failed: %s\n",
-                         nt_errstr(status)));
+                         strerror(ret)));
+               return map_nt_error_from_unix(ret);
        }
-       return status;
+       return NT_STATUS_OK;
 }
 
 NTSTATUS ctdbd_probe(const char *sockname, int timeout)
index 914ca4fdc8dff22c941db6ddb1171152937c667e..e024fe5466d84fbf560199bf1bf1bfdb2f6824b7 100644 (file)
@@ -761,12 +761,12 @@ static int db_ctdb_transaction_commit(struct db_context *db)
 
 again:
        /* tell ctdbd to commit to the other nodes */
-       rets = ctdbd_control_local(messaging_ctdbd_connection(),
-                                  CTDB_CONTROL_TRANS3_COMMIT,
-                                  h->ctx->db_id, 0,
-                                  db_ctdb_marshall_finish(h->m_write),
-                                  NULL, NULL, &status);
-       if (!NT_STATUS_IS_OK(rets) || status != 0) {
+       ret = ctdbd_control_local(messaging_ctdbd_connection(),
+                                 CTDB_CONTROL_TRANS3_COMMIT,
+                                 h->ctx->db_id, 0,
+                                 db_ctdb_marshall_finish(h->m_write),
+                                 NULL, NULL, &status);
+       if ((ret != 0) || status != 0) {
                /*
                 * The TRANS3_COMMIT control should only possibly fail when a
                 * recovery has been running concurrently. In any case, the db
@@ -853,6 +853,7 @@ static NTSTATUS db_ctdb_store(struct db_record *rec, TDB_DATA data, int flag)
 static NTSTATUS db_ctdb_send_schedule_for_deletion(struct db_record *rec)
 {
        NTSTATUS status;
+       int ret;
        struct ctdb_control_schedule_for_deletion *dd;
        TDB_DATA indata;
        int cstatus;
@@ -872,21 +873,21 @@ static NTSTATUS db_ctdb_send_schedule_for_deletion(struct db_record *rec)
        dd->keylen = rec->key.dsize;
        memcpy(dd->key, rec->key.dptr, rec->key.dsize);
 
-       status = ctdbd_control_local(messaging_ctdbd_connection(),
-                                    CTDB_CONTROL_SCHEDULE_FOR_DELETION,
-                                    crec->ctdb_ctx->db_id,
-                                    CTDB_CTRL_FLAG_NOREPLY, /* flags */
-                                    indata,
-                                    NULL, /* outdata */
-                                    NULL, /* errmsg */
-                                    &cstatus);
+       ret = ctdbd_control_local(messaging_ctdbd_connection(),
+                                 CTDB_CONTROL_SCHEDULE_FOR_DELETION,
+                                 crec->ctdb_ctx->db_id,
+                                 CTDB_CTRL_FLAG_NOREPLY, /* flags */
+                                 indata,
+                                 NULL, /* outdata */
+                                 NULL, /* errmsg */
+                                 &cstatus);
        talloc_free(indata.dptr);
 
-       if (!NT_STATUS_IS_OK(status) || cstatus != 0) {
+       if ((ret != 0) || cstatus != 0) {
                DEBUG(1, (__location__ " Error sending local control "
                          "SCHEDULE_FOR_DELETION: %s, cstatus = %d\n",
-                         nt_errstr(status), cstatus));
-               if (NT_STATUS_IS_OK(status)) {
+                         strerror(ret), cstatus));
+               if (ret != 0) {
                        status = NT_STATUS_UNSUCCESSFUL;
                }
        }
@@ -1550,7 +1551,6 @@ struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx,
        struct ctdbd_connection *conn;
        struct loadparm_context *lp_ctx;
        struct ctdb_db_priority prio;
-       NTSTATUS status;
        int cstatus;
        int ret;
 
@@ -1608,14 +1608,14 @@ struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx,
        prio.db_id = db_ctdb->db_id;
        prio.priority = lock_order;
 
-       status = ctdbd_control_local(
+       ret = ctdbd_control_local(
                conn, CTDB_CONTROL_SET_DB_PRIORITY, 0, 0,
                make_tdb_data((uint8_t *)&prio, sizeof(prio)),
                NULL, NULL, &cstatus);
 
-       if (!NT_STATUS_IS_OK(status) || (cstatus != 0)) {
+       if ((ret != 0) || (cstatus != 0)) {
                DEBUG(1, ("CTDB_CONTROL_SET_DB_PRIORITY failed: %s, %d\n",
-                         nt_errstr(status), cstatus));
+                         strerror(ret), cstatus));
                TALLOC_FREE(result);
                return NULL;
        }
@@ -1628,12 +1628,12 @@ struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx,
                indata = make_tdb_data((uint8_t *)&db_ctdb->db_id,
                                       sizeof(db_ctdb->db_id));
 
-               status = ctdbd_control_local(
+               ret = ctdbd_control_local(
                        conn, CTDB_CONTROL_SET_DB_READONLY, 0, 0, indata,
                        NULL, NULL, &cstatus);
-               if (!NT_STATUS_IS_OK(status) || (cstatus != 0)) {
+               if ((ret != 0) || (cstatus != 0)) {
                        DEBUG(1, ("CTDB_CONTROL_SET_DB_READONLY failed: "
-                                 "%s, %d\n", nt_errstr(status), cstatus));
+                                 "%s, %d\n", strerror(ret), cstatus));
                        TALLOC_FREE(result);
                        return NULL;
                }