summaryrefslogtreecommitdiff
path: root/ctdb/client
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2017-04-18 16:22:12 +1000
committerMartin Schwenke <martins@samba.org>2017-06-07 16:05:26 +0200
commit1469cfb0bebb4a8f89f02b30a7d6ecd53e4a88da (patch)
tree9305eeb1ec28929889f931290846b8737a2c0f42 /ctdb/client
parent025ebc0fc8785242192d24dfc2e680e0d621f468 (diff)
downloadsamba-1469cfb0bebb4a8f89f02b30a7d6ecd53e4a88da.tar.gz
ctdb-client: Create sync wrappers for managing message handlers
This wraps the entire async computation for setting and removing message handlers instead of calling multiple sync calls. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
Diffstat (limited to 'ctdb/client')
-rw-r--r--ctdb/client/client_message.c44
1 files changed, 33 insertions, 11 deletions
diff --git a/ctdb/client/client_message.c b/ctdb/client/client_message.c
index d35ee4c8925..c2e975aee57 100644
--- a/ctdb/client/client_message.c
+++ b/ctdb/client/client_message.c
@@ -544,22 +544,33 @@ int ctdb_client_set_message_handler(struct tevent_context *ev,
void *private_data)
{
TALLOC_CTX *mem_ctx;
+ struct tevent_req *req;
int ret;
+ bool status;
mem_ctx = talloc_new(client);
if (mem_ctx == NULL) {
return ENOMEM;
}
- ret = ctdb_ctrl_register_srvid(mem_ctx, ev, client, client->pnn,
- tevent_timeval_zero(), srvid);
- talloc_free(mem_ctx);
- if (ret != 0) {
+ req = ctdb_client_set_message_handler_send(mem_ctx, ev, client,
+ srvid, handler,
+ private_data);
+ if (req == NULL) {
+ talloc_free(mem_ctx);
+ return ENOMEM;
+ }
+
+ tevent_req_poll(req, ev);
+
+ status = ctdb_client_set_message_handler_recv(req, &ret);
+ if (! status) {
+ talloc_free(mem_ctx);
return ret;
}
- return srvid_register(client->srv, client, srvid,
- handler, private_data);
+ talloc_free(mem_ctx);
+ return 0;
}
int ctdb_client_remove_message_handler(struct tevent_context *ev,
@@ -567,19 +578,30 @@ int ctdb_client_remove_message_handler(struct tevent_context *ev,
uint64_t srvid, void *private_data)
{
TALLOC_CTX *mem_ctx;
+ struct tevent_req *req;
int ret;
+ bool status;
mem_ctx = talloc_new(client);
if (mem_ctx == NULL) {
return ENOMEM;
}
- ret = ctdb_ctrl_deregister_srvid(mem_ctx, ev, client, client->pnn,
- tevent_timeval_zero(), srvid);
- talloc_free(mem_ctx);
- if (ret != 0) {
+ req = ctdb_client_remove_message_handler_send(mem_ctx, ev, client,
+ srvid, private_data);
+ if (req == NULL) {
+ talloc_free(mem_ctx);
+ return ENOMEM;
+ }
+
+ tevent_req_poll(req, ev);
+
+ status = ctdb_client_remove_message_handler_recv(req, &ret);
+ if (! status) {
+ talloc_free(mem_ctx);
return ret;
}
- return srvid_deregister(client->srv, srvid, private_data);
+ talloc_free(mem_ctx);
+ return 0;
}