diff options
Diffstat (limited to 'ctdb')
-rw-r--r-- | ctdb/protocol/protocol_api.h | 5 | ||||
-rw-r--r-- | ctdb/protocol/protocol_client.c | 28 | ||||
-rw-r--r-- | ctdb/protocol/protocol_control.c | 26 | ||||
-rwxr-xr-x | ctdb/tests/cunit/protocol_test_002.sh | 2 | ||||
-rw-r--r-- | ctdb/tests/src/protocol_client_test.c | 18 |
5 files changed, 77 insertions, 2 deletions
diff --git a/ctdb/protocol/protocol_api.h b/ctdb/protocol/protocol_api.h index dfb75d49e35..dac0695b74f 100644 --- a/ctdb/protocol/protocol_api.h +++ b/ctdb/protocol/protocol_api.h @@ -597,6 +597,11 @@ void ctdb_req_control_db_push_confirm(struct ctdb_req_control *request, int ctdb_reply_control_db_push_confirm(struct ctdb_reply_control *reply, uint32_t *num_records); +void ctdb_req_control_db_open_flags(struct ctdb_req_control *request, + uint32_t db_id); +int ctdb_reply_control_db_open_flags(struct ctdb_reply_control *reply, + int *tdb_flags); + /* From protocol/protocol_debug.c */ void ctdb_packet_print(uint8_t *buf, size_t buflen, FILE *fp); diff --git a/ctdb/protocol/protocol_client.c b/ctdb/protocol/protocol_client.c index fe65a8a02c0..5d243a22423 100644 --- a/ctdb/protocol/protocol_client.c +++ b/ctdb/protocol/protocol_client.c @@ -2332,3 +2332,31 @@ int ctdb_reply_control_db_push_confirm(struct ctdb_reply_control *reply, } return reply->status; } + +/* CTDB_CONTROL_DB_OPEN_FLAGS */ + +void ctdb_req_control_db_open_flags(struct ctdb_req_control *request, + uint32_t db_id) +{ + request->opcode = CTDB_CONTROL_DB_OPEN_FLAGS; + request->pad = 0; + request->srvid = 0; + request->client_id = 0; + request->flags = 0; + + request->rdata.opcode = CTDB_CONTROL_DB_OPEN_FLAGS; + request->rdata.data.db_id = db_id; +} + +int ctdb_reply_control_db_open_flags(struct ctdb_reply_control *reply, + int *tdb_flags) +{ + if (reply->rdata.opcode != CTDB_CONTROL_DB_OPEN_FLAGS) { + return EPROTO; + } + + if (reply->status == 0) { + *tdb_flags = reply->rdata.data.tdb_flags; + } + return reply->status; +} diff --git a/ctdb/protocol/protocol_control.c b/ctdb/protocol/protocol_control.c index 022d9ff351d..f54281300b0 100644 --- a/ctdb/protocol/protocol_control.c +++ b/ctdb/protocol/protocol_control.c @@ -426,6 +426,10 @@ static size_t ctdb_req_control_data_len(struct ctdb_req_control_data *cd) case CTDB_CONTROL_DB_PUSH_CONFIRM: len = ctdb_uint32_len(cd->data.db_id); break; + + case CTDB_CONTROL_DB_OPEN_FLAGS: + len = ctdb_uint32_len(cd->data.db_id); + break; } return len; @@ -689,6 +693,10 @@ static void ctdb_req_control_data_push(struct ctdb_req_control_data *cd, case CTDB_CONTROL_DB_PUSH_CONFIRM: ctdb_uint32_push(cd->data.db_id, buf); break; + + case CTDB_CONTROL_DB_OPEN_FLAGS: + ctdb_uint32_push(cd->data.db_id, buf); + break; } } @@ -1019,6 +1027,11 @@ static int ctdb_req_control_data_pull(uint8_t *buf, size_t buflen, ret = ctdb_uint32_pull(buf, buflen, mem_ctx, &cd->data.db_id); break; + + case CTDB_CONTROL_DB_OPEN_FLAGS: + ret = ctdb_uint32_pull(buf, buflen, mem_ctx, + &cd->data.db_id); + break; } return ret; @@ -1380,6 +1393,10 @@ static size_t ctdb_reply_control_data_len(struct ctdb_reply_control_data *cd) case CTDB_CONTROL_DB_PUSH_CONFIRM: len = ctdb_uint32_len(cd->data.num_records); break; + + case CTDB_CONTROL_DB_OPEN_FLAGS: + len = ctdb_int32_len(cd->data.tdb_flags); + break; } return len; @@ -1532,6 +1549,10 @@ static void ctdb_reply_control_data_push(struct ctdb_reply_control_data *cd, case CTDB_CONTROL_DB_PUSH_CONFIRM: ctdb_uint32_push(cd->data.num_records, buf); break; + + case CTDB_CONTROL_DB_OPEN_FLAGS: + ctdb_int32_push(cd->data.tdb_flags, buf); + break; } } @@ -1719,6 +1740,11 @@ static int ctdb_reply_control_data_pull(uint8_t *buf, size_t buflen, ret = ctdb_uint32_pull(buf, buflen, mem_ctx, &cd->data.num_records); break; + + case CTDB_CONTROL_DB_OPEN_FLAGS: + ret = ctdb_int32_pull(buf, buflen, mem_ctx, + &cd->data.tdb_flags); + break; } return ret; diff --git a/ctdb/tests/cunit/protocol_test_002.sh b/ctdb/tests/cunit/protocol_test_002.sh index 929ff658718..0a3890eb24d 100755 --- a/ctdb/tests/cunit/protocol_test_002.sh +++ b/ctdb/tests/cunit/protocol_test_002.sh @@ -2,7 +2,7 @@ . "${TEST_SCRIPTS_DIR}/unit.sh" -last_control=148 +last_control=149 control_output=$( for i in $(seq 0 $last_control) ; do diff --git a/ctdb/tests/src/protocol_client_test.c b/ctdb/tests/src/protocol_client_test.c index c530dec72e8..48c0744151d 100644 --- a/ctdb/tests/src/protocol_client_test.c +++ b/ctdb/tests/src/protocol_client_test.c @@ -592,6 +592,10 @@ static void fill_ctdb_req_control_data(TALLOC_CTX *mem_ctx, cd->data.db_id = rand32(); break; + case CTDB_CONTROL_DB_OPEN_FLAGS: + cd->data.db_id = rand32(); + break; + } } @@ -988,6 +992,10 @@ static void verify_ctdb_req_control_data(struct ctdb_req_control_data *cd, assert(cd->data.db_id == cd2->data.db_id); break; + case CTDB_CONTROL_DB_OPEN_FLAGS: + assert(cd->data.db_id == cd2->data.db_id); + break; + } } @@ -1395,6 +1403,10 @@ static void fill_ctdb_reply_control_data(TALLOC_CTX *mem_ctx, cd->data.num_records = rand32(); break; + case CTDB_CONTROL_DB_OPEN_FLAGS: + cd->data.tdb_flags = rand32(); + break; + } } @@ -1732,6 +1744,10 @@ static void verify_ctdb_reply_control_data(struct ctdb_reply_control_data *cd, assert(cd->data.num_records == cd2->data.num_records); break; + case CTDB_CONTROL_DB_OPEN_FLAGS: + assert(cd->data.tdb_flags == cd2->data.tdb_flags); + break; + } } @@ -2174,7 +2190,7 @@ static void test_ctdb_reply_dmaster(void) talloc_free(mem_ctx); } -#define NUM_CONTROLS 149 +#define NUM_CONTROLS 150 static void test_ctdb_req_control_data(void) { |