From 0f8a6859e63b5d842caf231e7003732051815963 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 8 Aug 2008 10:55:11 +1000 Subject: cope with the control failing completely without returning a status (This used to be commit fe6a03e7b11cd859fddae5ba924ea5e071b8ccea) --- source3/lib/dbwrap_ctdb.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/dbwrap_ctdb.c b/source3/lib/dbwrap_ctdb.c index bd062b368a..8efc1ea290 100644 --- a/source3/lib/dbwrap_ctdb.c +++ b/source3/lib/dbwrap_ctdb.c @@ -652,17 +652,21 @@ again: tdb_transaction_cancel(h->ctx->wtdb->tdb); sleep(1); - /* work out what error code we will give if we - have to fail the operation */ - switch ((enum ctdb_trans2_commit_error)status) { - case CTDB_TRANS2_COMMIT_SUCCESS: - case CTDB_TRANS2_COMMIT_SOMEFAIL: - case CTDB_TRANS2_COMMIT_TIMEOUT: - failure_control = CTDB_CONTROL_TRANS2_ERROR; - break; - case CTDB_TRANS2_COMMIT_ALLFAIL: - failure_control = CTDB_CONTROL_TRANS2_FINISHED; - break; + if (!NT_STATUS_IS_OK(rets)) { + failure_control = CTDB_CONTROL_TRANS2_ERROR; + } else { + /* work out what error code we will give if we + have to fail the operation */ + switch ((enum ctdb_trans2_commit_error)status) { + case CTDB_TRANS2_COMMIT_SUCCESS: + case CTDB_TRANS2_COMMIT_SOMEFAIL: + case CTDB_TRANS2_COMMIT_TIMEOUT: + failure_control = CTDB_CONTROL_TRANS2_ERROR; + break; + case CTDB_TRANS2_COMMIT_ALLFAIL: + failure_control = CTDB_CONTROL_TRANS2_FINISHED; + break; + } } if (ctdb_replay_transaction(h) != 0) { @@ -687,13 +691,15 @@ again: return -1; } goto again; + } else { + failure_control = CTDB_CONTROL_TRANS2_ERROR; } /* do the real commit locally */ ret = tdb_transaction_commit(h->ctx->wtdb->tdb); if (ret != 0) { DEBUG(0,(__location__ " Failed to commit transaction\n")); - ctdbd_control_local(messaging_ctdbd_connection(), CTDB_CONTROL_TRANS2_ERROR, h->ctx->db_id, + ctdbd_control_local(messaging_ctdbd_connection(), failure_control, h->ctx->db_id, CTDB_CTRL_FLAG_NOREPLY, tdb_null, NULL, NULL, NULL); h->ctx->transaction = NULL; talloc_free(h); -- cgit