summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2017-08-30 15:13:53 +1000
committerMartin Schwenke <martins@samba.org>2017-09-21 08:53:26 +0200
commit7115378f7534f79043ab1b5d2b8fb265145537aa (patch)
tree9cae82108199ca88db411c5905b039360cf19f9b
parent5d12006e29a898c503a885115069fe26f2e084bc (diff)
downloadsamba-7115378f7534f79043ab1b5d2b8fb265145537aa.tar.gz
ctdb-protocol: Add marshalling for control CHECK_PID_SRVID
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13042 Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
-rw-r--r--ctdb/protocol/protocol_api.h5
-rw-r--r--ctdb/protocol/protocol_client.c28
-rw-r--r--ctdb/protocol/protocol_control.c22
-rw-r--r--ctdb/protocol/protocol_debug.c1
-rwxr-xr-xctdb/tests/cunit/protocol_test_101.sh2
-rw-r--r--ctdb/tests/src/protocol_common_ctdb.c13
-rw-r--r--ctdb/tests/src/protocol_ctdb_test.c2
7 files changed, 71 insertions, 2 deletions
diff --git a/ctdb/protocol/protocol_api.h b/ctdb/protocol/protocol_api.h
index 67f32a0b8cc..e15bb972e22 100644
--- a/ctdb/protocol/protocol_api.h
+++ b/ctdb/protocol/protocol_api.h
@@ -596,6 +596,11 @@ void ctdb_req_control_db_attach_replicated(struct ctdb_req_control *request,
int ctdb_reply_control_db_attach_replicated(struct ctdb_reply_control *reply,
uint32_t *db_id);
+void ctdb_req_control_check_pid_srvid(struct ctdb_req_control *request,
+ struct ctdb_pid_srvid *pid_srvid);
+int ctdb_reply_control_check_pid_srvid(struct ctdb_reply_control *reply,
+ int *status);
+
/* 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 d750260ff8a..a741b114dbd 100644
--- a/ctdb/protocol/protocol_client.c
+++ b/ctdb/protocol/protocol_client.c
@@ -2301,3 +2301,31 @@ int ctdb_reply_control_db_attach_replicated(struct ctdb_reply_control *reply,
}
return reply->status;
}
+
+/* CTDB_CONTROL_CHECK_PID_SRVID */
+
+void ctdb_req_control_check_pid_srvid(struct ctdb_req_control *request,
+ struct ctdb_pid_srvid *pid_srvid)
+{
+ request->opcode = CTDB_CONTROL_CHECK_PID_SRVID;
+ request->pad = 0;
+ request->srvid = 0;
+ request->client_id = 0;
+ request->flags = 0;
+
+ request->rdata.opcode = CTDB_CONTROL_CHECK_PID_SRVID;
+ request->rdata.data.pid_srvid = pid_srvid;
+}
+
+int ctdb_reply_control_check_pid_srvid(struct ctdb_reply_control *reply,
+ int *status)
+{
+ if (reply->rdata.opcode != CTDB_CONTROL_CHECK_PID_SRVID) {
+ return EPROTO;
+ }
+
+ *status = reply->status;
+ reply->status = 0;
+
+ return reply->status;
+}
diff --git a/ctdb/protocol/protocol_control.c b/ctdb/protocol/protocol_control.c
index f76a1af7228..5abe0379fe0 100644
--- a/ctdb/protocol/protocol_control.c
+++ b/ctdb/protocol/protocol_control.c
@@ -416,6 +416,10 @@ static size_t ctdb_req_control_data_len(struct ctdb_req_control_data *cd)
case CTDB_CONTROL_DB_ATTACH_REPLICATED:
len = ctdb_string_len(&cd->data.db_name);
break;
+
+ case CTDB_CONTROL_CHECK_PID_SRVID:
+ len = ctdb_pid_srvid_len(cd->data.pid_srvid);
+ break;
}
return len;
@@ -697,6 +701,10 @@ static void ctdb_req_control_data_push(struct ctdb_req_control_data *cd,
case CTDB_CONTROL_DB_ATTACH_REPLICATED:
ctdb_string_push(&cd->data.db_name, buf, &np);
break;
+
+ case CTDB_CONTROL_CHECK_PID_SRVID:
+ ctdb_pid_srvid_push(cd->data.pid_srvid, buf, &np);
+ break;
}
*npush = np;
@@ -1027,6 +1035,11 @@ static int ctdb_req_control_data_pull(uint8_t *buf, size_t buflen,
ret = ctdb_string_pull(buf, buflen, mem_ctx,
&cd->data.db_name, &np);
break;
+
+ case CTDB_CONTROL_CHECK_PID_SRVID:
+ ret = ctdb_pid_srvid_pull(buf, buflen, mem_ctx,
+ &cd->data.pid_srvid, &np);
+ break;
}
if (ret != 0) {
@@ -1400,6 +1413,9 @@ static size_t ctdb_reply_control_data_len(struct ctdb_reply_control_data *cd)
case CTDB_CONTROL_DB_ATTACH_REPLICATED:
len = ctdb_uint32_len(&cd->data.db_id);
break;
+
+ case CTDB_CONTROL_CHECK_PID_SRVID:
+ break;
}
return len;
@@ -1561,6 +1577,9 @@ static void ctdb_reply_control_data_push(struct ctdb_reply_control_data *cd,
case CTDB_CONTROL_DB_ATTACH_REPLICATED:
ctdb_uint32_push(&cd->data.db_id, buf, &np);
break;
+
+ case CTDB_CONTROL_CHECK_PID_SRVID:
+ break;
}
*npush = np;
@@ -1753,6 +1772,9 @@ static int ctdb_reply_control_data_pull(uint8_t *buf, size_t buflen,
case CTDB_CONTROL_DB_ATTACH_REPLICATED:
ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np);
break;
+
+ case CTDB_CONTROL_CHECK_PID_SRVID:
+ break;
}
if (ret != 0) {
diff --git a/ctdb/protocol/protocol_debug.c b/ctdb/protocol/protocol_debug.c
index 9cca76c5107..5a24d39cfba 100644
--- a/ctdb/protocol/protocol_debug.c
+++ b/ctdb/protocol/protocol_debug.c
@@ -239,6 +239,7 @@ static void ctdb_opcode_print(uint32_t opcode, FILE *fp)
{ CTDB_CONTROL_DB_PUSH_CONFIRM, "DB_PUSH_CONFIRM" },
{ CTDB_CONTROL_DB_OPEN_FLAGS, "DB_OPEN_FLAGS" },
{ CTDB_CONTROL_DB_ATTACH_REPLICATED, "DB_ATTACH_REPLICATED" },
+ { CTDB_CONTROL_CHECK_PID_SRVID, "CHECK_PID_SRVID" },
{ MAP_END, "" },
};
diff --git a/ctdb/tests/cunit/protocol_test_101.sh b/ctdb/tests/cunit/protocol_test_101.sh
index 800c6b598f7..8813e188d06 100755
--- a/ctdb/tests/cunit/protocol_test_101.sh
+++ b/ctdb/tests/cunit/protocol_test_101.sh
@@ -2,7 +2,7 @@
. "${TEST_SCRIPTS_DIR}/unit.sh"
-last_control=150
+last_control=151
generate_control_output ()
{
diff --git a/ctdb/tests/src/protocol_common_ctdb.c b/ctdb/tests/src/protocol_common_ctdb.c
index 26b1ad65d80..0c3a9a89f2f 100644
--- a/ctdb/tests/src/protocol_common_ctdb.c
+++ b/ctdb/tests/src/protocol_common_ctdb.c
@@ -603,6 +603,12 @@ void fill_ctdb_req_control_data(TALLOC_CTX *mem_ctx,
fill_ctdb_string(mem_ctx, &cd->data.db_name);
assert(cd->data.db_name != NULL);
break;
+
+ case CTDB_CONTROL_CHECK_PID_SRVID:
+ cd->data.pid_srvid = talloc(mem_ctx, struct ctdb_pid_srvid);
+ assert(cd->data.pid_srvid != NULL);
+ fill_ctdb_pid_srvid(mem_ctx, cd->data.pid_srvid);
+ break;
}
}
@@ -1005,6 +1011,9 @@ void verify_ctdb_req_control_data(struct ctdb_req_control_data *cd,
verify_ctdb_string(&cd->data.db_name, &cd2->data.db_name);
break;
+ case CTDB_CONTROL_CHECK_PID_SRVID:
+ verify_ctdb_pid_srvid(cd->data.pid_srvid, cd2->data.pid_srvid);
+ break;
}
}
@@ -1417,6 +1426,8 @@ void fill_ctdb_reply_control_data(TALLOC_CTX *mem_ctx,
cd->data.db_id = rand32();
break;
+ case CTDB_CONTROL_CHECK_PID_SRVID:
+ break;
}
}
@@ -1762,6 +1773,8 @@ void verify_ctdb_reply_control_data(struct ctdb_reply_control_data *cd,
assert(cd->data.db_id == cd2->data.db_id);
break;
+ case CTDB_CONTROL_CHECK_PID_SRVID:
+ break;
}
}
diff --git a/ctdb/tests/src/protocol_ctdb_test.c b/ctdb/tests/src/protocol_ctdb_test.c
index ade37c2a552..a13901f8363 100644
--- a/ctdb/tests/src/protocol_ctdb_test.c
+++ b/ctdb/tests/src/protocol_ctdb_test.c
@@ -283,7 +283,7 @@ PROTOCOL_CTDB4_TEST(struct ctdb_req_dmaster, ctdb_req_dmaster,
PROTOCOL_CTDB4_TEST(struct ctdb_reply_dmaster, ctdb_reply_dmaster,
CTDB_REPLY_DMASTER);
-#define NUM_CONTROLS 151
+#define NUM_CONTROLS 152
PROTOCOL_CTDB2_TEST(struct ctdb_req_control_data, ctdb_req_control_data);
PROTOCOL_CTDB2_TEST(struct ctdb_reply_control_data, ctdb_reply_control_data);