This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
_exit(0);
}
+/*
+ *
+ */
+static void ctdb_packet_dump(struct ctdb_req_header *hdr)
+{
+ if (DEBUGLEVEL < 10) {
+ return;
+ }
+ DEBUGADD(10, ("len=%d, magic=%x, vers=%d, gen=%d, op=%d, reqid=%d\n",
+ (int)hdr->length, (int)hdr->ctdb_magic,
+ (int)hdr->ctdb_version, (int)hdr->generation,
+ (int)hdr->operation, (int)hdr->reqid));
+}
+
/*
* Register a srvid with ctdbd
*/
int32_t cstatus=-1;
NTSTATUS status;
status = ctdbd_control(conn,
- CTDB_CURRENT_NODE, CTDB_CONTROL_GET_VNN, 0,
+ CTDB_CURRENT_NODE, CTDB_CONTROL_GET_PNN, 0,
tdb_null, NULL, NULL, &cstatus);
if (!NT_STATUS_IS_OK(status)) {
cluster_fatal("ctdbd_control failed\n");
* Do we have a complete ctdb packet in the queue?
*/
-static BOOL ctdb_req_complete(const struct data_blob *data,
+static bool ctdb_req_complete(const struct data_blob *data,
size_t *length,
void *private_data)
{
if (msglen < sizeof(struct ctdb_req_header)) {
DEBUG(0, ("Got invalid msglen: %d, expected at least %d for "
- "the req_header\n", msglen,
- sizeof(struct ctdb_req_header)));
+ "the req_header\n", (int)msglen,
+ (int)sizeof(struct ctdb_req_header)));
cluster_fatal("ctdbd protocol error\n");
}
&blob, result, result,
(ndr_pull_flags_fn_t)ndr_pull_messaging_rec);
+ if (DEBUGLEVEL >= 10) {
+ DEBUG(10, ("ctdb_pull_messaging_rec:\n"));
+ NDR_PRINT_DEBUG(messaging_rec, result);
+ }
+
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("ndr_pull_struct_blob failed: %s\n",
nt_errstr(status)));
if (NT_STATUS_EQUAL(status, NT_STATUS_NETWORK_BUSY)) {
/* EAGAIN */
goto again;
+ } else if (NT_STATUS_EQUAL(status, NT_STATUS_RETRY)) {
+ /* EAGAIN */
+ goto again;
}
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(3, ("packet_fd_read failed: %s\n", nt_errstr(status)));
+ DEBUG(0, ("packet_fd_read failed: %s\n", nt_errstr(status)));
cluster_fatal("ctdbd died\n");
}
+ next_pkt:
+
ZERO_STRUCT(state);
state.mem_ctx = mem_ctx;
/*
* Not enough data
*/
+ DEBUG(10, ("not enough data from ctdb socket, retrying\n"));
goto again;
}
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(3, ("Could not read packet: %s\n", nt_errstr(status)));
+ DEBUG(0, ("Could not read packet: %s\n", nt_errstr(status)));
cluster_fatal("ctdbd died\n");
}
hdr = (struct ctdb_req_header *)state.req.data;
+ DEBUG(10, ("Received ctdb packet\n"));
+ ctdb_packet_dump(hdr);
+
if (hdr->operation == CTDB_REQ_MESSAGE) {
struct timed_event *evt;
struct deferred_msg_state *msg_state;
if (conn->msg_ctx == NULL) {
DEBUG(1, ("Got a message without having a msg ctx, "
- "dropping msg %llu\n", msg->srvid));
- goto again;
+ "dropping msg %llu\n",
+ (long long unsigned)msg->srvid));
+ goto next_pkt;
}
if ((conn->release_ip_handler != NULL)
conn->release_ip_handler((const char *)msg->data,
conn->release_ip_priv);
TALLOC_FREE(hdr);
- goto again;
+ goto next_pkt;
}
if (!(msg_state = TALLOC_P(NULL, struct deferred_msg_state))) {
DEBUG(0, ("talloc failed\n"));
TALLOC_FREE(hdr);
- goto again;
+ goto next_pkt;
}
if (!(msg_state->rec = ctdb_pull_messaging_rec(
DEBUG(0, ("ctdbd_pull_messaging_rec failed\n"));
TALLOC_FREE(msg_state);
TALLOC_FREE(hdr);
- goto again;
+ goto next_pkt;
}
TALLOC_FREE(hdr);
DEBUG(0, ("event_add_timed failed\n"));
TALLOC_FREE(msg_state);
TALLOC_FREE(hdr);
- goto again;
+ goto next_pkt;
}
- goto again;
+ goto next_pkt;
}
if (hdr->reqid != reqid) {
r.srvid = dst_srvid;
r.datalen = blob.length;
+ DEBUG(10, ("ctdbd_messaging_send: Sending ctdb packet\n"));
+ ctdb_packet_dump(&r.hdr);
+
status = packet_send(
conn->pkt, 2,
data_blob_const(&r, offsetof(struct ctdb_req_message, data)),
req.srvid = srvid;
req.datalen = data.dsize;
+ DEBUG(10, ("ctdbd_control: Sending ctdb packet\n"));
+ ctdb_packet_dump(&req.hdr);
+
status = packet_send(
conn->pkt, 2,
data_blob_const(&req, offsetof(struct ctdb_req_control, data)),
- data);
+ data_blob_const(data.dptr, data.dsize));
if (!NT_STATUS_IS_OK(status)) {
DEBUG(3, ("packet_send failed: %s\n", nt_errstr(status)));
/*
* see if a remote process exists
*/
-BOOL ctdbd_process_exists(struct ctdbd_connection *conn, uint32 vnn, pid_t pid)
+bool ctdbd_process_exists(struct ctdbd_connection *conn, uint32 vnn, pid_t pid)
{
NTSTATUS status;
TDB_DATA data;
req.db_id = db_id;
req.keylen = key.dsize;
+ DEBUG(10, ("ctdbd_migrate: Sending ctdb packet\n"));
+ ctdb_packet_dump(&req.hdr);
+
status = packet_send(
conn->pkt, 2,
data_blob_const(&req, offsetof(struct ctdb_req_call, data)),
- key);
+ data_blob_const(key.dptr, key.dsize));
if (!NT_STATUS_IS_OK(status)) {
DEBUG(3, ("packet_send failed: %s\n", nt_errstr(status)));
status = packet_send(
conn->pkt, 2,
data_blob_const(&req, offsetof(struct ctdb_req_call, data)),
- key);
+ data_blob_const(key.dptr, key.dsize));
if (!NT_STATUS_IS_OK(status)) {
DEBUG(3, ("packet_send failed: %s\n", nt_errstr(status)));
status = packet_fd_read_sync(conn->pkt);
+ if (NT_STATUS_EQUAL(status, NT_STATUS_RETRY)) {
+ /*
+ * There might be more in the queue
+ */
+ continue;
+ }
+
if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE)) {
status = NT_STATUS_OK;
}
if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("packet_fd_read_sync failed: %s\n", nt_errstr(status)));
cluster_fatal("ctdbd died\n");
}
}