CTDB_CURRENT_NODE, CTDB_CONTROL_GET_PNN, 0, 0,
tdb_null, NULL, NULL, &cstatus);
if (!NT_STATUS_IS_OK(status)) {
- cluster_fatal("ctdbd_control failed\n");
+ DEBUG(1, ("ctdbd_control failed: %s\n", nt_errstr(status)));
+ return status;
}
*vnn = (uint32_t)cstatus;
return status;
CTDB_CONTROL_GET_NODEMAP, 0, 0,
tdb_null, talloc_tos(), &outdata, &cstatus);
if (!NT_STATUS_IS_OK(status)) {
- cluster_fatal("ctdbd_control failed\n");
+ DEBUG(1, ("ctdbd_control failed: %s\n", nt_errstr(status)));
+ return false;
}
if ((cstatus != 0) || (outdata.dptr == NULL)) {
DEBUG(2, ("Received invalid ctdb data\n"));
{
struct ctdb_packet_context *result;
const char *sockname = lp_ctdbd_socket();
- struct sockaddr_un addr;
+ struct sockaddr_un addr = { 0, };
int fd;
socklen_t salen;
return map_nt_error_from_unix(errno);
}
- ZERO_STRUCT(addr);
addr.sun_family = AF_UNIX;
snprintf(addr.sun_path, sizeof(addr.sun_path), "%s", sockname);
}
/*
- * remotely fetch a record (read-only)
+ * Fetch a record and parse it
*/
-NTSTATUS ctdbd_fetch(struct ctdbd_connection *conn, uint32_t db_id,
- TDB_DATA key, TALLOC_CTX *mem_ctx, TDB_DATA *data,
- bool local_copy)
+NTSTATUS ctdbd_parse(struct ctdbd_connection *conn, uint32_t db_id,
+ TDB_DATA key, bool local_copy,
+ void (*parser)(TDB_DATA key, TDB_DATA data,
+ void *private_data),
+ void *private_data)
{
struct ctdb_req_call req;
struct ctdb_reply_call *reply;
goto fail;
}
- data->dsize = reply->datalen;
- if (data->dsize == 0) {
- data->dptr = NULL;
- goto done;
- }
-
- data->dptr = (uint8 *)talloc_memdup(mem_ctx, &reply->data[0],
- reply->datalen);
- if (data->dptr == NULL) {
- DEBUG(0, ("talloc failed\n"));
- status = NT_STATUS_NO_MEMORY;
+ if (reply->datalen == 0) {
+ /*
+ * Treat an empty record as non-existing
+ */
+ status = NT_STATUS_NOT_FOUND;
goto fail;
}
- done:
+ parser(key, make_tdb_data(&reply->data[0], reply->datalen),
+ private_data);
+
status = NT_STATUS_OK;
fail:
TALLOC_FREE(reply);
return status;
}
+NTSTATUS ctdbd_probe(void)
+{
+ /*
+ * Do a very early check if ctdbd is around to avoid an abort and core
+ * later
+ */
+ struct ctdbd_connection *conn = NULL;
+ NTSTATUS status;
+
+ status = ctdbd_messaging_connection(talloc_tos(), &conn);
+
+ /*
+ * We only care if we can connect.
+ */
+ TALLOC_FREE(conn);
+
+ return status;
+}
+
#else
+NTSTATUS ctdbd_probe(void)
+{
+ return NT_STATUS_OK;
+}
+
NTSTATUS ctdbd_messaging_send_blob(struct ctdbd_connection *conn,
uint32_t dst_vnn, uint64_t dst_srvid,
const uint8_t *buf, size_t buflen)