#include "lib/util/debug.h"
#include "lib/util/samba_util.h"
-#include "ctdb_logging.h"
#include "ctdb_private.h"
#include "ctdb_client.h"
#include "common/reqid.h"
#include "common/system.h"
#include "common/common.h"
+#include "common/logging.h"
/*
allocate a packet for use in client<->daemon communication
c->errorlen);
}
- /* state->outdata now uses resources from c so we dont want c
+ /* state->outdata now uses resources from c so we don't want c
to just dissappear from under us while state is still alive
*/
talloc_steal(state, c);
uint32_t lmaster, TALLOC_CTX *mem_ctx, struct timeval timeout)
{
TDB_DATA indata;
- struct ctdb_control_pulldb *pull;
+ struct ctdb_pulldb *pull;
struct ctdb_client_control_state *state;
- pull = talloc(mem_ctx, struct ctdb_control_pulldb);
+ pull = talloc(mem_ctx, struct ctdb_pulldb);
CTDB_NO_MEMORY_NULL(ctdb, pull);
pull->db_id = dbid;
pull->lmaster = lmaster;
- indata.dsize = sizeof(struct ctdb_control_pulldb);
+ indata.dsize = sizeof(struct ctdb_pulldb);
indata.dptr = (unsigned char *)pull;
state = ctdb_control_send(ctdb, destnode, 0,
uint32_t destnode,
const char *name, uint32_t value)
{
- struct ctdb_control_set_tunable *t;
+ struct ctdb_tunable_old *t;
TDB_DATA data;
int32_t res;
int ret;
- data.dsize = offsetof(struct ctdb_control_set_tunable, name) + strlen(name) + 1;
+ data.dsize = offsetof(struct ctdb_tunable_old, name) + strlen(name) + 1;
data.dptr = talloc_size(ctdb, data.dsize);
CTDB_NO_MEMORY(ctdb, data.dptr);
- t = (struct ctdb_control_set_tunable *)data.dptr;
+ t = (struct ctdb_tunable_old *)data.dptr;
t->length = strlen(name)+1;
memcpy(t->name, name, t->length);
t->value = value;
struct timeval timeout, uint32_t destnode,
TALLOC_CTX *mem_ctx,
const ctdb_sock_addr *addr,
- struct ctdb_control_public_ip_info **_info)
+ struct ctdb_public_ip_info_old **_info)
{
int ret;
TDB_DATA indata;
TDB_DATA outdata;
int32_t res;
- struct ctdb_control_public_ip_info *info;
+ struct ctdb_public_ip_info_old *info;
uint32_t len;
uint32_t i;
return -1;
}
- len = offsetof(struct ctdb_control_public_ip_info, ifaces);
+ len = offsetof(struct ctdb_public_ip_info_old, ifaces);
if (len > outdata.dsize) {
DEBUG(DEBUG_ERR,(__location__ " ctdb_control for get public ip info "
"returned invalid data with size %u > %u\n",
return -1;
}
- info = (struct ctdb_control_public_ip_info *)outdata.dptr;
- len += info->num*sizeof(struct ctdb_control_iface_info);
+ info = (struct ctdb_public_ip_info_old *)outdata.dptr;
+ len += info->num*sizeof(struct ctdb_iface);
if (len > outdata.dsize) {
DEBUG(DEBUG_ERR,(__location__ " ctdb_control for get public ip info "
info->ifaces[i].name[CTDB_IFACE_SIZE] = '\0';
}
- *_info = (struct ctdb_control_public_ip_info *)talloc_memdup(mem_ctx,
+ *_info = (struct ctdb_public_ip_info_old *)talloc_memdup(mem_ctx,
outdata.dptr,
outdata.dsize);
talloc_free(outdata.dptr);
int ctdb_ctrl_get_ifaces(struct ctdb_context *ctdb,
struct timeval timeout, uint32_t destnode,
TALLOC_CTX *mem_ctx,
- struct ctdb_control_get_ifaces **_ifaces)
+ struct ctdb_iface_list_old **_ifaces)
{
int ret;
TDB_DATA outdata;
int32_t res;
- struct ctdb_control_get_ifaces *ifaces;
+ struct ctdb_iface_list_old *ifaces;
uint32_t len;
uint32_t i;
return -1;
}
- len = offsetof(struct ctdb_control_get_ifaces, ifaces);
+ len = offsetof(struct ctdb_iface_list_old, ifaces);
if (len > outdata.dsize) {
DEBUG(DEBUG_ERR,(__location__ " ctdb_control for get ifaces "
"returned invalid data with size %u > %u\n",
return -1;
}
- ifaces = (struct ctdb_control_get_ifaces *)outdata.dptr;
- len += ifaces->num*sizeof(struct ctdb_control_iface_info);
+ ifaces = (struct ctdb_iface_list_old *)outdata.dptr;
+ len += ifaces->num*sizeof(struct ctdb_iface);
if (len > outdata.dsize) {
DEBUG(DEBUG_ERR,(__location__ " ctdb_control for get ifaces "
ifaces->ifaces[i].name[CTDB_IFACE_SIZE] = '\0';
}
- *_ifaces = (struct ctdb_control_get_ifaces *)talloc_memdup(mem_ctx,
+ *_ifaces = (struct ctdb_iface_list_old *)talloc_memdup(mem_ctx,
outdata.dptr,
outdata.dsize);
talloc_free(outdata.dptr);
int ctdb_ctrl_set_iface_link(struct ctdb_context *ctdb,
struct timeval timeout, uint32_t destnode,
TALLOC_CTX *mem_ctx,
- const struct ctdb_control_iface_info *info)
+ const struct ctdb_iface *info)
{
int ret;
TDB_DATA indata;
/*
get all tunables
*/
-int ctdb_ctrl_get_all_tunables(struct ctdb_context *ctdb,
- struct timeval timeout,
+int ctdb_ctrl_get_all_tunables(struct ctdb_context *ctdb,
+ struct timeval timeout,
uint32_t destnode,
- struct ctdb_tunable *tunables)
+ struct ctdb_tunable_list *tunables)
{
TDB_DATA outdata;
int ret;
if (outdata.dsize != sizeof(*tunables)) {
DEBUG(DEBUG_ERR,(__location__ " bad data size %u in ctdb_ctrl_get_all_tunables should be %u\n",
(unsigned)outdata.dsize, (unsigned)sizeof(*tunables)));
- return -1;
+ return -1;
}
- *tunables = *(struct ctdb_tunable *)outdata.dptr;
+ *tunables = *(struct ctdb_tunable_list *)outdata.dptr;
talloc_free(outdata.dptr);
return 0;
}
/*
add a public address to a node
*/
-int ctdb_ctrl_add_public_ip(struct ctdb_context *ctdb,
- struct timeval timeout,
- uint32_t destnode,
- struct ctdb_control_ip_iface *pub)
+int ctdb_ctrl_add_public_ip(struct ctdb_context *ctdb,
+ struct timeval timeout, uint32_t destnode,
+ struct ctdb_addr_info_old *pub)
{
TDB_DATA data;
int32_t res;
int ret;
- data.dsize = offsetof(struct ctdb_control_ip_iface, iface) + pub->len;
+ data.dsize = offsetof(struct ctdb_addr_info_old, iface) + pub->len;
data.dptr = (unsigned char *)pub;
ret = ctdb_control(ctdb, destnode, 0, CTDB_CONTROL_ADD_PUBLIC_IP, 0, data, NULL,
/*
delete a public address from a node
*/
-int ctdb_ctrl_del_public_ip(struct ctdb_context *ctdb,
- struct timeval timeout,
- uint32_t destnode,
- struct ctdb_control_ip_iface *pub)
+int ctdb_ctrl_del_public_ip(struct ctdb_context *ctdb,
+ struct timeval timeout, uint32_t destnode,
+ struct ctdb_addr_info_old *pub)
{
TDB_DATA data;
int32_t res;
int ret;
- data.dsize = offsetof(struct ctdb_control_ip_iface, iface) + pub->len;
+ data.dsize = offsetof(struct ctdb_addr_info_old, iface) + pub->len;
data.dptr = (unsigned char *)pub;
ret = ctdb_control(ctdb, destnode, 0, CTDB_CONTROL_DEL_PUBLIC_IP, 0, data, NULL,
int ctdb_ctrl_killtcp(struct ctdb_context *ctdb,
struct timeval timeout,
uint32_t destnode,
- struct ctdb_tcp_connection *killtcp)
+ struct ctdb_connection *killtcp)
{
TDB_DATA data;
int32_t res;
int ret;
- data.dsize = sizeof(struct ctdb_tcp_connection);
+ data.dsize = sizeof(struct ctdb_connection);
data.dptr = (unsigned char *)killtcp;
ret = ctdb_control(ctdb, destnode, 0, CTDB_CONTROL_KILL_TCP, 0, data, NULL,
/*
send a gratious arp
*/
-int ctdb_ctrl_gratious_arp(struct ctdb_context *ctdb,
- struct timeval timeout,
- uint32_t destnode,
- ctdb_sock_addr *addr,
- const char *ifname)
+int ctdb_ctrl_gratious_arp(struct ctdb_context *ctdb,
+ struct timeval timeout, uint32_t destnode,
+ ctdb_sock_addr *addr, const char *ifname)
{
TDB_DATA data;
int32_t res;
int ret, len;
- struct ctdb_control_gratious_arp *gratious_arp;
+ struct ctdb_addr_info_old *gratious_arp;
TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
len = strlen(ifname)+1;
- gratious_arp = talloc_size(tmp_ctx,
- offsetof(struct ctdb_control_gratious_arp, iface) + len);
+ gratious_arp = talloc_size(tmp_ctx,
+ offsetof(struct ctdb_addr_info_old, iface) + len);
CTDB_NO_MEMORY(ctdb, gratious_arp);
gratious_arp->addr = *addr;
memcpy(&gratious_arp->iface[0], ifname, len);
- data.dsize = offsetof(struct ctdb_control_gratious_arp, iface) + len;
+ data.dsize = offsetof(struct ctdb_addr_info_old, iface) + len;
data.dptr = (unsigned char *)gratious_arp;
- ret = ctdb_control(ctdb, destnode, 0, CTDB_CONTROL_SEND_GRATIOUS_ARP, 0, data, NULL,
+ ret = ctdb_control(ctdb, destnode, 0, CTDB_CONTROL_SEND_GRATUITOUS_ARP, 0, data, NULL,
NULL, &res, &timeout, NULL);
if (ret != 0 || res != 0) {
DEBUG(DEBUG_ERR,(__location__ " ctdb_control for gratious_arp failed\n"));
struct timeval timeout, uint32_t destnode,
TALLOC_CTX *mem_ctx,
ctdb_sock_addr *addr,
- struct ctdb_control_tcp_tickle_list **list)
+ struct ctdb_tickle_list_old **list)
{
int ret;
TDB_DATA data, outdata;
return -1;
}
- *list = (struct ctdb_control_tcp_tickle_list *)outdata.dptr;
+ *list = (struct ctdb_tickle_list_old *)outdata.dptr;
return status;
}
get the list of server ids that are registered on a node
*/
int ctdb_ctrl_get_server_id_list(struct ctdb_context *ctdb,
- TALLOC_CTX *mem_ctx,
- struct timeval timeout, uint32_t destnode,
- struct ctdb_server_id_list **svid_list)
+ TALLOC_CTX *mem_ctx,
+ struct timeval timeout, uint32_t destnode,
+ struct ctdb_client_id_list_old **svid_list)
{
int ret;
TDB_DATA outdata;
return -1;
}
- *svid_list = (struct ctdb_server_id_list *)talloc_steal(mem_ctx, outdata.dptr);
-
+ *svid_list = (struct ctdb_client_id_list_old *)talloc_steal(mem_ctx, outdata.dptr);
+
return 0;
}
uint32_t i, res;
struct ctdb_node_capabilities *ret;
- nodes = list_of_connected_nodes(ctdb, nodemap, mem_ctx, true);
+ nodes = list_of_active_nodes(ctdb, nodemap, mem_ctx, true);
ret = talloc_array(mem_ctx, struct ctdb_node_capabilities,
nodemap->num);
}
-struct server_id {
- uint64_t pid;
- uint32_t task_id;
- uint32_t vnn;
- uint64_t unique_id;
-};
-
-static struct server_id server_id_fetch(struct ctdb_context *ctdb, uint32_t reqid)
+static struct ctdb_server_id server_id_fetch(struct ctdb_context *ctdb, uint32_t reqid)
{
- struct server_id id;
+ struct ctdb_server_id id;
id.pid = getpid();
id.task_id = reqid;
/* This is basically a copy from Samba's server_id.*. However, a
* dependency chain stops us from using Samba's version, so use a
* renamed copy until a better solution is found. */
-static bool ctdb_server_id_equal(struct server_id *id1, struct server_id *id2)
+static bool ctdb_server_id_equal(struct ctdb_server_id *id1, struct ctdb_server_id *id2)
{
if (id1->pid != id2->pid) {
return false;
return true;
}
-static bool server_id_exists(struct ctdb_context *ctdb, struct server_id *id)
+static bool server_id_exists(struct ctdb_context *ctdb, struct ctdb_server_id *id)
{
struct ctdb_client_id sid;
int ret;
return false;
}
-
-enum g_lock_type {
- G_LOCK_READ = 0,
- G_LOCK_WRITE = 1,
-};
-
-struct g_lock_rec {
- enum g_lock_type type;
- struct server_id id;
-};
-
-struct g_lock_recs {
- unsigned int num;
- struct g_lock_rec *lock;
-};
-
static bool g_lock_parse(TALLOC_CTX *mem_ctx, TDB_DATA data,
- struct g_lock_recs **locks)
+ struct ctdb_g_lock_list **locks)
{
- struct g_lock_recs *recs;
+ struct ctdb_g_lock_list *recs;
- recs = talloc_zero(mem_ctx, struct g_lock_recs);
+ recs = talloc_zero(mem_ctx, struct ctdb_g_lock_list);
if (recs == NULL) {
return false;
}
goto done;
}
- if (data.dsize % sizeof(struct g_lock_rec) != 0) {
+ if (data.dsize % sizeof(struct ctdb_g_lock) != 0) {
DEBUG(DEBUG_ERR, (__location__ "invalid data size %lu in g_lock record\n",
(unsigned long)data.dsize));
talloc_free(recs);
return false;
}
- recs->num = data.dsize / sizeof(struct g_lock_rec);
+ recs->num = data.dsize / sizeof(struct ctdb_g_lock);
recs->lock = talloc_memdup(mem_ctx, data.dptr, data.dsize);
if (recs->lock == NULL) {
talloc_free(recs);
{
TDB_DATA key, data;
struct ctdb_record_handle *h;
- struct g_lock_recs *locks;
- struct server_id id;
+ struct ctdb_g_lock_list *locks;
+ struct ctdb_server_id id;
struct timeval t_start;
int i;
i = 0;
while (i < locks->num) {
- if (ctdb_server_id_equal(&locks->lock[i].id, &id)) {
+ if (ctdb_server_id_equal(&locks->lock[i].sid, &id)) {
/* Internal error */
talloc_free(h);
return false;
}
- if (!server_id_exists(ctdb_db->ctdb, &locks->lock[i].id)) {
+ if (!server_id_exists(ctdb_db->ctdb, &locks->lock[i].sid)) {
if (i < locks->num-1) {
locks->lock[i] = locks->lock[locks->num-1];
}
goto again;
}
- locks->lock = talloc_realloc(locks, locks->lock, struct g_lock_rec,
+ locks->lock = talloc_realloc(locks, locks->lock, struct ctdb_g_lock,
locks->num+1);
if (locks->lock == NULL) {
talloc_free(h);
return false;
}
- locks->lock[locks->num].type = G_LOCK_WRITE;
- locks->lock[locks->num].id = id;
+ locks->lock[locks->num].type = CTDB_G_LOCK_WRITE;
+ locks->lock[locks->num].sid = id;
locks->num++;
data.dptr = (uint8_t *)locks->lock;
- data.dsize = locks->num * sizeof(struct g_lock_rec);
+ data.dsize = locks->num * sizeof(struct ctdb_g_lock);
if (ctdb_record_store(h, data) != 0) {
DEBUG(DEBUG_ERR, ("g_lock: failed to write transaction lock for "
{
TDB_DATA key, data;
struct ctdb_record_handle *h;
- struct g_lock_recs *locks;
- struct server_id id;
+ struct ctdb_g_lock_list *locks;
+ struct ctdb_server_id id;
int i;
bool found = false;
id = server_id_fetch(ctdb_db->ctdb, reqid);
for (i=0; i<locks->num; i++) {
- if (ctdb_server_id_equal(&locks->lock[i].id, &id)) {
+ if (ctdb_server_id_equal(&locks->lock[i].sid, &id)) {
if (i < locks->num-1) {
locks->lock[i] = locks->lock[locks->num-1];
}
}
data.dptr = (uint8_t *)locks->lock;
- data.dsize = locks->num * sizeof(struct g_lock_rec);
+ data.dsize = locks->num * sizeof(struct ctdb_g_lock);
if (ctdb_record_store(h, data) != 0) {
talloc_free(h);
return 0;
}
-/* When forking the main daemon and the child process needs to connect
- * back to the daemon as a client process, this function can be used
- * to change the ctdb context from daemon into client mode. The child
- * process must be created using ctdb_fork() and not fork() -
- * ctdb_fork() does some necessary housekeeping.
- */
-int switch_from_server_to_client(struct ctdb_context *ctdb, const char *fmt, ...)
-{
- int ret;
- va_list ap;
-
- /* Add extra information so we can identify this in the logs */
- va_start(ap, fmt);
- debug_extra = talloc_strdup_append(talloc_vasprintf(NULL, fmt, ap), ":");
- va_end(ap);
-
- /* get a new event context */
- ctdb->ev = tevent_context_init(ctdb);
- tevent_loop_allow_nesting(ctdb->ev);
-
- /* Connect to main CTDB daemon */
- ret = ctdb_socket_connect(ctdb);
- if (ret != 0) {
- DEBUG(DEBUG_ALERT, (__location__ " Failed to init ctdb client\n"));
- return -1;
- }
-
- ctdb->can_send_controls = true;
-
- return 0;
-}
-
/*
get the status of running the monitor eventscripts: NULL means never run.
*/
}
-int ctdb_ctrl_set_ban(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, struct ctdb_ban_time *bantime)
+int ctdb_ctrl_set_ban(struct ctdb_context *ctdb, struct timeval timeout,
+ uint32_t destnode, struct ctdb_ban_state *bantime)
{
int ret;
TDB_DATA data;
}
-int ctdb_ctrl_get_ban(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, TALLOC_CTX *mem_ctx, struct ctdb_ban_time **bantime)
+int ctdb_ctrl_get_ban(struct ctdb_context *ctdb, struct timeval timeout,
+ uint32_t destnode, TALLOC_CTX *mem_ctx,
+ struct ctdb_ban_state **bantime)
{
int ret;
TDB_DATA outdata;
return -1;
}
- *bantime = (struct ctdb_ban_time *)talloc_steal(mem_ctx, outdata.dptr);
+ *bantime = (struct ctdb_ban_state *)talloc_steal(mem_ctx, outdata.dptr);
talloc_free(tmp_ctx);
return 0;