1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

ctdb-daemon: Add client code to talk to new event daemon

This fixes the build and now new eventd is integrated completely in CTDB.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
This commit is contained in:
Amitay Isaacs 2018-06-21 17:16:07 +10:00 committed by Martin Schwenke
parent 8250072a81
commit db548f4852
3 changed files with 27 additions and 24 deletions

View File

@ -129,12 +129,12 @@ static void ctdb_health_callback(struct ctdb_context *ctdb, int status, void *p)
rddata.dptr = (uint8_t *)&rd;
rddata.dsize = sizeof(rd);
if (status == -ECANCELED) {
if (status == ECANCELED) {
DEBUG(DEBUG_ERR,("Monitoring event was cancelled\n"));
goto after_change_status;
}
if (status == -ETIME) {
if (status == ETIME) {
ctdb->monitor->event_script_timeouts++;
if (ctdb->monitor->event_script_timeouts >=

View File

@ -43,7 +43,8 @@
#include "common/sock_io.h"
#include "common/path.h"
#include "protocol/protocol_api.h"
#include "protocol/protocol_util.h"
#include "event/event_protocol_api.h"
/*
* Setting up event daemon
@ -293,6 +294,7 @@ static int eventd_client_write(struct eventd_context *ectx,
void *private_data),
void *private_data)
{
struct ctdb_event_header header;
struct eventd_client_state *state;
int ret;
@ -317,16 +319,19 @@ static int eventd_client_write(struct eventd_context *ectx,
talloc_set_destructor(state, eventd_client_state_destructor);
sock_packet_header_set_reqid(&request->header, state->reqid);
header.reqid = state->reqid;
state->buflen = ctdb_event_request_len(request);
state->buflen = ctdb_event_request_len(&header, request);
state->buf = talloc_size(state, state->buflen);
if (state->buf == NULL) {
talloc_free(state);
return -1;
}
ret = ctdb_event_request_push(request, state->buf, &state->buflen);
ret = ctdb_event_request_push(&header,
request,
state->buf,
&state->buflen);
if (ret != 0) {
talloc_free(state);
return -1;
@ -358,6 +363,7 @@ static void eventd_client_read(uint8_t *buf, size_t buflen,
struct eventd_context *ectx = talloc_get_type_abort(
private_data, struct eventd_context);
struct eventd_client_state *state;
struct ctdb_event_header header;
struct ctdb_event_reply *reply;
int ret;
@ -367,33 +373,27 @@ static void eventd_client_read(uint8_t *buf, size_t buflen,
return;
}
reply = talloc_zero(ectx, struct ctdb_event_reply);
if (reply == NULL) {
return;
}
ret = ctdb_event_reply_pull(buf, buflen, reply, reply);
ret = ctdb_event_reply_pull(buf, buflen, &header, ectx, &reply);
if (ret != 0) {
D_ERR("Invalid packet received, ret=%d\n", ret);
talloc_free(reply);
return;
}
if (buflen != reply->header.length) {
if (buflen != header.length) {
D_ERR("Packet size mismatch %zu != %"PRIu32"\n",
buflen, reply->header.length);
buflen, header.length);
talloc_free(reply);
return;
}
state = reqid_find(ectx->idr, reply->header.reqid,
state = reqid_find(ectx->idr, header.reqid,
struct eventd_client_state);
if (state == NULL) {
talloc_free(reply);
return;
}
if (state->reqid != reply->header.reqid) {
if (state->reqid != header.reqid) {
talloc_free(reply);
return;
}
@ -439,12 +439,14 @@ static int eventd_client_run(struct eventd_context *ectx,
state->callback = callback;
state->private_data = private_data;
rdata.event = event;
rdata.component = "legacy";
rdata.event = ctdb_event_to_string(event);
rdata.args = arg_str;
rdata.timeout = timeout;
rdata.arg_str = arg_str;
rdata.flags = 0;
request.rdata.command = CTDB_EVENT_COMMAND_RUN;
request.rdata.data.run = &rdata;
request.cmd = CTDB_EVENT_CMD_RUN;
request.data.run = &rdata;
ret = eventd_client_write(ectx, state, &request,
eventd_client_run_done, state);
@ -463,7 +465,7 @@ static void eventd_client_run_done(struct ctdb_event_reply *reply,
private_data, struct eventd_client_run_state);
state = talloc_steal(state->ectx, state);
state->callback(reply->rdata.result, state->private_data);
state->callback(reply->result, state->private_data);
talloc_free(state);
}
@ -560,7 +562,7 @@ static void ctdb_event_script_run_done(int result, void *private_data)
struct ctdb_event_script_run_state *state = talloc_get_type_abort(
private_data, struct ctdb_event_script_run_state);
if (result == -ETIME) {
if (result == ETIME) {
switch (state->event) {
case CTDB_EVENT_START_RECOVERY:
case CTDB_EVENT_RECOVERED:
@ -714,7 +716,7 @@ int ctdb_event_script_args(struct ctdb_context *ctdb, enum ctdb_event call,
tevent_loop_once(ctdb->ev);
}
if (state.status == -ETIME) {
if (state.status == ETIME) {
/* Don't ban self if CTDB is starting up or shutting down */
if (call != CTDB_EVENT_INIT && call != CTDB_EVENT_SHUTDOWN) {
DEBUG(DEBUG_ERR,

View File

@ -558,6 +558,7 @@ def build(bld):
ctdb-database-conf
ctdb-event-conf
ctdb-legacy-conf
ctdb-event-protocol
talloc tevent tdb-wrap tdb talloc_report''' +
ib_deps,
install_path='${SBINDIR}',