mirror of
https://github.com/samba-team/samba.git
synced 2025-01-21 18:04:06 +03:00
ctdb-tools: Handle leader broadcasts in ctdb tool
Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
parent
ec90f36cc6
commit
17ba15ccd8
@ -40,6 +40,7 @@
|
||||
#include "common/logging.h"
|
||||
#include "common/path.h"
|
||||
#include "protocol/protocol.h"
|
||||
#include "protocol/protocol_basic.h"
|
||||
#include "protocol/protocol_api.h"
|
||||
#include "protocol/protocol_util.h"
|
||||
#include "common/system_socket.h"
|
||||
@ -73,7 +74,7 @@ struct ctdb_context {
|
||||
struct tevent_context *ev;
|
||||
struct ctdb_client_context *client;
|
||||
struct ctdb_node_map *nodemap;
|
||||
uint32_t pnn, cmd_pnn;
|
||||
uint32_t pnn, cmd_pnn, leader_pnn;
|
||||
uint64_t srvid;
|
||||
};
|
||||
|
||||
@ -724,6 +725,25 @@ static int run_helper(TALLOC_CTX *mem_ctx, const char *command,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void leader_handler(uint64_t srvid,
|
||||
TDB_DATA data,
|
||||
void *private_data)
|
||||
{
|
||||
struct ctdb_context *ctdb = talloc_get_type_abort(
|
||||
private_data, struct ctdb_context);
|
||||
uint32_t leader_pnn;
|
||||
size_t np;
|
||||
int ret;
|
||||
|
||||
ret = ctdb_uint32_pull(data.dptr, data.dsize, &leader_pnn, &np);
|
||||
if (ret != 0) {
|
||||
/* Ignore packet */
|
||||
return;
|
||||
}
|
||||
|
||||
ctdb->leader_pnn = leader_pnn;
|
||||
}
|
||||
|
||||
/*
|
||||
* Command Functions
|
||||
*/
|
||||
@ -6216,6 +6236,17 @@ static int process_command(const struct ctdb_cmd *cmd, int argc,
|
||||
goto fail;
|
||||
}
|
||||
|
||||
ctdb->leader_pnn = CTDB_UNKNOWN_PNN;
|
||||
ret = ctdb_client_set_message_handler(ctdb->ev,
|
||||
ctdb->client,
|
||||
CTDB_SRVID_LEADER,
|
||||
leader_handler,
|
||||
ctdb);
|
||||
if (ret != 0) {
|
||||
fprintf(stderr, "Failed to setup leader handler\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
ret = cmd->fn(tmp_ctx, ctdb, argc-1, argv+1);
|
||||
talloc_free(tmp_ctx);
|
||||
return ret;
|
||||
|
Loading…
x
Reference in New Issue
Block a user