diff options
author | Volker Lendecke <vl@samba.org> | 2015-10-02 20:42:05 -0700 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2015-10-07 23:54:06 +0200 |
commit | 2d00fcda69152688427e59d63425f0969a95f971 (patch) | |
tree | 02de8d759676278d239d0aa9ea7bdf8efd64ad55 /source3/lib | |
parent | a039463d823ad4e7fbff5a3f8e4416c184e40f36 (diff) | |
download | samba-2d00fcda69152688427e59d63425f0969a95f971.tar.gz |
lib: Make ctdbd_control_local return 0/errno
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/ctdbd_conn.c | 40 | ||||
-rw-r--r-- | source3/lib/dbwrap/dbwrap_ctdb.c | 48 |
2 files changed, 42 insertions, 46 deletions
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c index 0ba0d7505fd..3d9f8f01b27 100644 --- a/source3/lib/ctdbd_conn.c +++ b/source3/lib/ctdbd_conn.c @@ -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 *)®_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) diff --git a/source3/lib/dbwrap/dbwrap_ctdb.c b/source3/lib/dbwrap/dbwrap_ctdb.c index 914ca4fdc8d..e024fe5466d 100644 --- a/source3/lib/dbwrap/dbwrap_ctdb.c +++ b/source3/lib/dbwrap/dbwrap_ctdb.c @@ -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; } |