diff options
-rw-r--r-- | ctdb/server/ctdb_monitor.c | 4 | ||||
-rw-r--r-- | ctdb/server/eventscript.c | 46 | ||||
-rw-r--r-- | ctdb/wscript | 1 |
3 files changed, 27 insertions, 24 deletions
diff --git a/ctdb/server/ctdb_monitor.c b/ctdb/server/ctdb_monitor.c index 59d4a915fd8..68884ac5c11 100644 --- a/ctdb/server/ctdb_monitor.c +++ b/ctdb/server/ctdb_monitor.c @@ -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 >= diff --git a/ctdb/server/eventscript.c b/ctdb/server/eventscript.c index c3624f26fa8..de05443e66c 100644 --- a/ctdb/server/eventscript.c +++ b/ctdb/server/eventscript.c @@ -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, diff --git a/ctdb/wscript b/ctdb/wscript index f91631feaf1..8ae3f89b1e7 100644 --- a/ctdb/wscript +++ b/ctdb/wscript @@ -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}', |