#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
void *private_data),
void *private_data)
{
+ struct ctdb_event_header header;
struct eventd_client_state *state;
int ret;
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;
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;
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;
}
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);
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);
}
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:
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,