mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
ctdb-daemon: Use reqid abstraction
Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
This commit is contained in:
parent
9fd4d07ca6
commit
b25c1135a7
@ -28,6 +28,7 @@
|
||||
#include <stdlib.h>
|
||||
#include "../include/ctdb_private.h"
|
||||
#include "lib/util/dlinklist.h"
|
||||
#include "common/reqid.h"
|
||||
|
||||
/*
|
||||
allocate a packet for use in client<->daemon communication
|
||||
@ -153,7 +154,7 @@ static void ctdb_client_reply_call(struct ctdb_context *ctdb, struct ctdb_req_he
|
||||
struct ctdb_reply_call *c = (struct ctdb_reply_call *)hdr;
|
||||
struct ctdb_client_call_state *state;
|
||||
|
||||
state = ctdb_reqid_find(ctdb, hdr->reqid, struct ctdb_client_call_state);
|
||||
state = reqid_find(ctdb->idr, hdr->reqid, struct ctdb_client_call_state);
|
||||
if (state == NULL) {
|
||||
DEBUG(DEBUG_ERR,(__location__ " reqid %u not found\n", hdr->reqid));
|
||||
return;
|
||||
@ -344,7 +345,7 @@ int ctdb_call_recv(struct ctdb_client_call_state *state, struct ctdb_call *call)
|
||||
*/
|
||||
static int ctdb_client_call_destructor(struct ctdb_client_call_state *state)
|
||||
{
|
||||
ctdb_reqid_remove(state->ctdb_db->ctdb, state->reqid);
|
||||
reqid_remove(state->ctdb_db->ctdb->idr, state->reqid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -444,7 +445,7 @@ struct ctdb_client_call_state *ctdb_call_send(struct ctdb_db_context *ctdb_db,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
state->reqid = ctdb_reqid_new(ctdb, state);
|
||||
state->reqid = reqid_new(ctdb->idr, state);
|
||||
state->ctdb_db = ctdb_db;
|
||||
talloc_set_destructor(state, ctdb_client_call_destructor);
|
||||
|
||||
@ -978,7 +979,7 @@ static void ctdb_client_reply_control(struct ctdb_context *ctdb,
|
||||
struct ctdb_reply_control *c = (struct ctdb_reply_control *)hdr;
|
||||
struct ctdb_client_control_state *state;
|
||||
|
||||
state = ctdb_reqid_find(ctdb, hdr->reqid, struct ctdb_client_control_state);
|
||||
state = reqid_find(ctdb->idr, hdr->reqid, struct ctdb_client_control_state);
|
||||
if (state == NULL) {
|
||||
DEBUG(DEBUG_ERR,(__location__ " reqid %u not found\n", hdr->reqid));
|
||||
return;
|
||||
@ -1020,7 +1021,7 @@ static void ctdb_client_reply_control(struct ctdb_context *ctdb,
|
||||
*/
|
||||
static int ctdb_client_control_destructor(struct ctdb_client_control_state *state)
|
||||
{
|
||||
ctdb_reqid_remove(state->ctdb, state->reqid);
|
||||
reqid_remove(state->ctdb->idr, state->reqid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1071,7 +1072,7 @@ struct ctdb_client_control_state *ctdb_control_send(struct ctdb_context *ctdb,
|
||||
CTDB_NO_MEMORY_NULL(ctdb, state);
|
||||
|
||||
state->ctdb = ctdb;
|
||||
state->reqid = ctdb_reqid_new(ctdb, state);
|
||||
state->reqid = reqid_new(ctdb->idr, state);
|
||||
state->state = CTDB_CONTROL_WAIT;
|
||||
state->errormsg = NULL;
|
||||
|
||||
@ -3313,10 +3314,13 @@ struct ctdb_context *ctdb_init(struct event_context *ev)
|
||||
return NULL;
|
||||
}
|
||||
ctdb->ev = ev;
|
||||
ctdb->idr = idr_init(ctdb);
|
||||
/* Wrap early to exercise code. */
|
||||
ctdb->lastid = INT_MAX-200;
|
||||
CTDB_NO_MEMORY_NULL(ctdb, ctdb->idr);
|
||||
ret = reqid_init(ctdb, INT_MAX-200, &ctdb->idr);
|
||||
if (ret != 0) {
|
||||
DEBUG(DEBUG_ERR, ("reqid_init failed (%s)\n", strerror(ret)));
|
||||
talloc_free(ctdb);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = srvid_init(ctdb, &ctdb->srv);
|
||||
if (ret != 0) {
|
||||
@ -4101,7 +4105,7 @@ struct ctdb_transaction_handle {
|
||||
static int ctdb_transaction_destructor(struct ctdb_transaction_handle *h)
|
||||
{
|
||||
g_lock_unlock(h, h->g_lock_db, h->lock_name, h->reqid);
|
||||
ctdb_reqid_remove(h->ctdb_db->ctdb, h->reqid);
|
||||
reqid_remove(h->ctdb_db->ctdb->idr, h->reqid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -4149,7 +4153,7 @@ struct ctdb_transaction_handle *ctdb_transaction_start(struct ctdb_db_context *c
|
||||
return NULL;
|
||||
}
|
||||
|
||||
h->reqid = ctdb_reqid_new(h->ctdb_db->ctdb, h);
|
||||
h->reqid = reqid_new(h->ctdb_db->ctdb->idr, h);
|
||||
|
||||
if (!g_lock_lock(h, h->g_lock_db, h->lock_name, h->reqid)) {
|
||||
DEBUG(DEBUG_ERR, (__location__ " Error locking g_lock.tdb\n"));
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "system/filesys.h"
|
||||
#include "system/wait.h"
|
||||
#include "../include/ctdb_private.h"
|
||||
#include "common/reqid.h"
|
||||
|
||||
/*
|
||||
return error string for last error
|
||||
@ -199,54 +200,6 @@ uint32_t ctdb_hash(const TDB_DATA *key)
|
||||
return tdb_jenkins_hash(discard_const(key));
|
||||
}
|
||||
|
||||
/*
|
||||
a type checking varient of idr_find
|
||||
*/
|
||||
static void *_idr_find_type(struct idr_context *idp, int id, const char *type, const char *location)
|
||||
{
|
||||
void *p = idr_find(idp, id);
|
||||
if (p && talloc_check_name(p, type) == NULL) {
|
||||
DEBUG(DEBUG_ERR,("%s idr_find_type expected type %s but got %s\n",
|
||||
location, type, talloc_get_name(p)));
|
||||
return NULL;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
uint32_t ctdb_reqid_new(struct ctdb_context *ctdb, void *state)
|
||||
{
|
||||
int id = idr_get_new_above(ctdb->idr, state, ctdb->lastid+1, INT_MAX);
|
||||
if (id < 0) {
|
||||
DEBUG(DEBUG_DEBUG, ("Reqid wrap!\n"));
|
||||
id = idr_get_new(ctdb->idr, state, INT_MAX);
|
||||
}
|
||||
ctdb->lastid = id;
|
||||
return id;
|
||||
}
|
||||
|
||||
void *_ctdb_reqid_find(struct ctdb_context *ctdb, uint32_t reqid, const char *type, const char *location)
|
||||
{
|
||||
void *p;
|
||||
|
||||
p = _idr_find_type(ctdb->idr, reqid, type, location);
|
||||
if (p == NULL) {
|
||||
DEBUG(DEBUG_WARNING, ("Could not find idr:%u\n",reqid));
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
void ctdb_reqid_remove(struct ctdb_context *ctdb, uint32_t reqid)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = idr_remove(ctdb->idr, reqid);
|
||||
if (ret != 0) {
|
||||
DEBUG(DEBUG_ERR, ("Removing idr that does not exist\n"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static uint32_t ctdb_marshall_record_size(TDB_DATA key,
|
||||
struct ctdb_ltdb_header *header,
|
||||
|
@ -453,8 +453,7 @@ struct ctdb_context {
|
||||
uint32_t num_connected;
|
||||
unsigned flags;
|
||||
uint32_t capabilities;
|
||||
struct idr_context *idr;
|
||||
int lastid;
|
||||
struct reqid_context *idr;
|
||||
struct ctdb_node **nodes; /* array of nodes in the cluster - indexed by vnn */
|
||||
struct ctdb_vnn *vnn; /* list of public ip addresses and interfaces */
|
||||
struct ctdb_vnn *single_ip_vnn; /* a structure for the single ip */
|
||||
@ -813,10 +812,6 @@ int ctdb_call_local(struct ctdb_db_context *ctdb_db, struct ctdb_call *call,
|
||||
int ctdb_socket_connect(struct ctdb_context *ctdb);
|
||||
void ctdb_client_read_cb(uint8_t *data, size_t cnt, void *args);
|
||||
|
||||
uint32_t ctdb_reqid_new(struct ctdb_context *ctdb, void *state);
|
||||
void *_ctdb_reqid_find(struct ctdb_context *ctdb, uint32_t reqid, const char *type, const char *location);
|
||||
void ctdb_reqid_remove(struct ctdb_context *ctdb, uint32_t reqid);
|
||||
|
||||
void ctdb_request_control(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
|
||||
void ctdb_reply_control(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "system/filesys.h"
|
||||
#include "../include/ctdb_private.h"
|
||||
#include "../common/rb_tree.h"
|
||||
#include "common/reqid.h"
|
||||
|
||||
struct ctdb_sticky_record {
|
||||
struct ctdb_context *ctdb;
|
||||
@ -334,7 +335,7 @@ static void ctdb_become_dmaster(struct ctdb_db_context *ctdb_db,
|
||||
header.dmaster = ctdb->pnn;
|
||||
header.flags = record_flags;
|
||||
|
||||
state = ctdb_reqid_find(ctdb, hdr->reqid, struct ctdb_call_state);
|
||||
state = reqid_find(ctdb->idr, hdr->reqid, struct ctdb_call_state);
|
||||
|
||||
if (state) {
|
||||
if (state->call->flags & CTDB_CALL_FLAG_VACUUM_MIGRATION) {
|
||||
@ -1159,7 +1160,7 @@ void ctdb_reply_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
|
||||
struct ctdb_reply_call *c = (struct ctdb_reply_call *)hdr;
|
||||
struct ctdb_call_state *state;
|
||||
|
||||
state = ctdb_reqid_find(ctdb, hdr->reqid, struct ctdb_call_state);
|
||||
state = reqid_find(ctdb->idr, hdr->reqid, struct ctdb_call_state);
|
||||
if (state == NULL) {
|
||||
DEBUG(DEBUG_ERR, (__location__ " reqid %u not found\n", hdr->reqid));
|
||||
return;
|
||||
@ -1319,7 +1320,7 @@ void ctdb_reply_error(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
|
||||
struct ctdb_reply_error *c = (struct ctdb_reply_error *)hdr;
|
||||
struct ctdb_call_state *state;
|
||||
|
||||
state = ctdb_reqid_find(ctdb, hdr->reqid, struct ctdb_call_state);
|
||||
state = reqid_find(ctdb->idr, hdr->reqid, struct ctdb_call_state);
|
||||
if (state == NULL) {
|
||||
DEBUG(DEBUG_ERR,("pnn %u Invalid reqid %u in ctdb_reply_error\n",
|
||||
ctdb->pnn, hdr->reqid));
|
||||
@ -1348,7 +1349,7 @@ void ctdb_reply_error(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
|
||||
static int ctdb_call_destructor(struct ctdb_call_state *state)
|
||||
{
|
||||
DLIST_REMOVE(state->ctdb_db->pending_calls, state);
|
||||
ctdb_reqid_remove(state->ctdb_db->ctdb, state->reqid);
|
||||
reqid_remove(state->ctdb_db->ctdb->idr, state->reqid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1363,8 +1364,8 @@ static void ctdb_call_resend(struct ctdb_call_state *state)
|
||||
state->generation = state->ctdb_db->generation;
|
||||
|
||||
/* use a new reqid, in case the old reply does eventually come in */
|
||||
ctdb_reqid_remove(ctdb, state->reqid);
|
||||
state->reqid = ctdb_reqid_new(ctdb, state);
|
||||
reqid_remove(ctdb->idr, state->reqid);
|
||||
state->reqid = reqid_new(ctdb->idr, state);
|
||||
state->c->hdr.reqid = state->reqid;
|
||||
|
||||
/* update the generation count for this request, so its valid with the new vnn_map */
|
||||
@ -1473,7 +1474,7 @@ struct ctdb_call_state *ctdb_daemon_call_send_remote(struct ctdb_db_context *ctd
|
||||
state->call = talloc(state, struct ctdb_call);
|
||||
CTDB_NO_MEMORY_NULL(ctdb, state->call);
|
||||
|
||||
state->reqid = ctdb_reqid_new(ctdb, state);
|
||||
state->reqid = reqid_new(ctdb->idr, state);
|
||||
state->ctdb_db = ctdb_db;
|
||||
talloc_set_destructor(state, ctdb_call_destructor);
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "lib/util/dlinklist.h"
|
||||
#include "lib/tdb_wrap/tdb_wrap.h"
|
||||
#include "lib/util/talloc_report.h"
|
||||
#include "common/reqid.h"
|
||||
|
||||
|
||||
struct ctdb_control_state {
|
||||
@ -785,7 +786,7 @@ void ctdb_reply_control(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
|
||||
struct ctdb_control_state *state;
|
||||
const char *errormsg = NULL;
|
||||
|
||||
state = ctdb_reqid_find(ctdb, hdr->reqid, struct ctdb_control_state);
|
||||
state = reqid_find(ctdb->idr, hdr->reqid, struct ctdb_control_state);
|
||||
if (state == NULL) {
|
||||
DEBUG(DEBUG_ERR,("pnn %u Invalid reqid %u in ctdb_reply_control\n",
|
||||
ctdb->pnn, hdr->reqid));
|
||||
@ -814,7 +815,7 @@ void ctdb_reply_control(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
|
||||
|
||||
static int ctdb_control_destructor(struct ctdb_control_state *state)
|
||||
{
|
||||
ctdb_reqid_remove(state->ctdb, state->reqid);
|
||||
reqid_remove(state->ctdb->idr, state->reqid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -881,7 +882,7 @@ int ctdb_daemon_send_control(struct ctdb_context *ctdb, uint32_t destnode,
|
||||
state = talloc(private_data?private_data:ctdb, struct ctdb_control_state);
|
||||
CTDB_NO_MEMORY(ctdb, state);
|
||||
|
||||
state->reqid = ctdb_reqid_new(ctdb, state);
|
||||
state->reqid = reqid_new(ctdb->idr, state);
|
||||
state->callback = callback;
|
||||
state->private_data = private_data;
|
||||
state->ctdb = ctdb;
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "../include/ctdb_private.h"
|
||||
#include "../common/rb_tree.h"
|
||||
#include <sys/socket.h>
|
||||
#include "common/reqid.h"
|
||||
|
||||
struct ctdb_client_pid_list {
|
||||
struct ctdb_client_pid_list *next, *prev;
|
||||
@ -157,7 +158,7 @@ static void daemon_message_handler(uint64_t srvid, TDB_DATA data,
|
||||
*/
|
||||
int daemon_register_message_handler(struct ctdb_context *ctdb, uint32_t client_id, uint64_t srvid)
|
||||
{
|
||||
struct ctdb_client *client = ctdb_reqid_find(ctdb, client_id, struct ctdb_client);
|
||||
struct ctdb_client *client = reqid_find(ctdb->idr, client_id, struct ctdb_client);
|
||||
int res;
|
||||
if (client == NULL) {
|
||||
DEBUG(DEBUG_ERR,("Bad client_id in daemon_request_register_message_handler\n"));
|
||||
@ -182,7 +183,7 @@ int daemon_register_message_handler(struct ctdb_context *ctdb, uint32_t client_i
|
||||
*/
|
||||
int daemon_deregister_message_handler(struct ctdb_context *ctdb, uint32_t client_id, uint64_t srvid)
|
||||
{
|
||||
struct ctdb_client *client = ctdb_reqid_find(ctdb, client_id, struct ctdb_client);
|
||||
struct ctdb_client *client = reqid_find(ctdb->idr, client_id, struct ctdb_client);
|
||||
if (client == NULL) {
|
||||
DEBUG(DEBUG_ERR,("Bad client_id in daemon_request_deregister_message_handler\n"));
|
||||
return -1;
|
||||
@ -229,7 +230,7 @@ static int ctdb_client_destructor(struct ctdb_client *client)
|
||||
struct ctdb_db_context *ctdb_db;
|
||||
|
||||
ctdb_takeover_client_destructor_hook(client);
|
||||
ctdb_reqid_remove(client->ctdb, client->client_id);
|
||||
reqid_remove(client->ctdb->idr, client->client_id);
|
||||
client->ctdb->num_clients--;
|
||||
|
||||
if (client->num_persistent_updates != 0) {
|
||||
@ -387,7 +388,7 @@ static void daemon_incoming_packet_wrap(void *p, struct ctdb_req_header *hdr)
|
||||
return;
|
||||
}
|
||||
|
||||
client = ctdb_reqid_find(w->ctdb, w->client_id, struct ctdb_client);
|
||||
client = reqid_find(w->ctdb->idr, w->client_id, struct ctdb_client);
|
||||
if (client == NULL) {
|
||||
DEBUG(DEBUG_ERR,(__location__ " Packet for disconnected client %u\n",
|
||||
w->client_id));
|
||||
@ -448,7 +449,7 @@ static int deferred_fetch_queue_destructor(struct ctdb_deferred_fetch_queue *dfq
|
||||
|
||||
DLIST_REMOVE(dfq->deferred_calls, dfc);
|
||||
|
||||
client = ctdb_reqid_find(dfc->w->ctdb, dfc->w->client_id, struct ctdb_client);
|
||||
client = reqid_find(dfc->w->ctdb->idr, dfc->w->client_id, struct ctdb_client);
|
||||
if (client == NULL) {
|
||||
DEBUG(DEBUG_ERR,(__location__ " Packet for disconnected client %u\n",
|
||||
dfc->w->client_id));
|
||||
@ -931,7 +932,7 @@ static void ctdb_accept_client(struct event_context *ev, struct fd_event *fde,
|
||||
|
||||
client->ctdb = ctdb;
|
||||
client->fd = fd;
|
||||
client->client_id = ctdb_reqid_new(ctdb, client);
|
||||
client->client_id = reqid_new(ctdb->idr, client);
|
||||
client->pid = peer_pid;
|
||||
|
||||
client_pid = talloc(client, struct ctdb_client_pid_list);
|
||||
@ -1654,7 +1655,7 @@ static int ctdb_client_notify_destructor(struct ctdb_client_notify_list *nl)
|
||||
int32_t ctdb_control_register_notify(struct ctdb_context *ctdb, uint32_t client_id, TDB_DATA indata)
|
||||
{
|
||||
struct ctdb_client_notify_register *notify = (struct ctdb_client_notify_register *)indata.dptr;
|
||||
struct ctdb_client *client = ctdb_reqid_find(ctdb, client_id, struct ctdb_client);
|
||||
struct ctdb_client *client = reqid_find(ctdb->idr, client_id, struct ctdb_client);
|
||||
struct ctdb_client_notify_list *nl;
|
||||
|
||||
DEBUG(DEBUG_INFO,("Register srvid %llu for client %d\n", (unsigned long long)notify->srvid, client_id));
|
||||
@ -1703,7 +1704,7 @@ int32_t ctdb_control_register_notify(struct ctdb_context *ctdb, uint32_t client_
|
||||
int32_t ctdb_control_deregister_notify(struct ctdb_context *ctdb, uint32_t client_id, TDB_DATA indata)
|
||||
{
|
||||
struct ctdb_client_notify_deregister *notify = (struct ctdb_client_notify_deregister *)indata.dptr;
|
||||
struct ctdb_client *client = ctdb_reqid_find(ctdb, client_id, struct ctdb_client);
|
||||
struct ctdb_client *client = reqid_find(ctdb->idr, client_id, struct ctdb_client);
|
||||
struct ctdb_client_notify_list *nl;
|
||||
|
||||
DEBUG(DEBUG_INFO,("Deregister srvid %llu for client %d\n", (unsigned long long)notify->srvid, client_id));
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "lib/tdb_wrap/tdb_wrap.h"
|
||||
#include "lib/util/dlinklist.h"
|
||||
#include <ctype.h>
|
||||
#include "common/reqid.h"
|
||||
|
||||
#define PERSISTENT_HEALTH_TDB "persistent_health.tdb"
|
||||
|
||||
@ -1096,7 +1097,7 @@ int32_t ctdb_control_db_attach(struct ctdb_context *ctdb, TDB_DATA indata,
|
||||
* recovery daemons.
|
||||
*/
|
||||
if (client_id != 0) {
|
||||
client = ctdb_reqid_find(ctdb, client_id, struct ctdb_client);
|
||||
client = reqid_find(ctdb->idr, client_id, struct ctdb_client);
|
||||
}
|
||||
if (client != NULL) {
|
||||
/* If the node is inactive it is not part of the cluster
|
||||
@ -1236,7 +1237,7 @@ int32_t ctdb_control_db_detach(struct ctdb_context *ctdb, TDB_DATA indata,
|
||||
* Do the actual detach only if the control comes from other daemons.
|
||||
*/
|
||||
if (client_id != 0) {
|
||||
client = ctdb_reqid_find(ctdb, client_id, struct ctdb_client);
|
||||
client = reqid_find(ctdb->idr, client_id, struct ctdb_client);
|
||||
if (client != NULL) {
|
||||
/* forward the control to all the nodes */
|
||||
ctdb_daemon_send_control(ctdb, CTDB_BROADCAST_ALL, 0,
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "lib/tdb_wrap/tdb_wrap.h"
|
||||
#include "tdb.h"
|
||||
#include "../include/ctdb_private.h"
|
||||
#include "common/reqid.h"
|
||||
|
||||
struct ctdb_persistent_state {
|
||||
struct ctdb_context *ctdb;
|
||||
@ -174,7 +175,7 @@ int32_t ctdb_control_trans3_commit(struct ctdb_context *ctdb,
|
||||
return -1;
|
||||
}
|
||||
|
||||
client = ctdb_reqid_find(ctdb, c->client_id, struct ctdb_client);
|
||||
client = reqid_find(ctdb->idr, c->client_id, struct ctdb_client);
|
||||
if (client == NULL) {
|
||||
DEBUG(DEBUG_ERR,(__location__ " can not match persistent_store "
|
||||
"to a client. Returning error\n"));
|
||||
@ -277,7 +278,7 @@ int32_t ctdb_control_start_persistent_update(struct ctdb_context *ctdb,
|
||||
struct ctdb_req_control *c,
|
||||
TDB_DATA recdata)
|
||||
{
|
||||
struct ctdb_client *client = ctdb_reqid_find(ctdb, c->client_id, struct ctdb_client);
|
||||
struct ctdb_client *client = reqid_find(ctdb->idr, c->client_id, struct ctdb_client);
|
||||
|
||||
if (client == NULL) {
|
||||
DEBUG(DEBUG_ERR,(__location__ " can not match start_persistent_update to a client. Returning error\n"));
|
||||
@ -298,7 +299,7 @@ int32_t ctdb_control_cancel_persistent_update(struct ctdb_context *ctdb,
|
||||
struct ctdb_req_control *c,
|
||||
TDB_DATA recdata)
|
||||
{
|
||||
struct ctdb_client *client = ctdb_reqid_find(ctdb, c->client_id, struct ctdb_client);
|
||||
struct ctdb_client *client = reqid_find(ctdb->idr, c->client_id, struct ctdb_client);
|
||||
|
||||
if (client == NULL) {
|
||||
DEBUG(DEBUG_ERR,(__location__ " can not match cancel_persistent_update to a client. Returning error\n"));
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "includes.h"
|
||||
#include "../include/ctdb_private.h"
|
||||
#include "../common/rb_tree.h"
|
||||
#include "common/reqid.h"
|
||||
|
||||
|
||||
#define SERVER_ID_KEY_SIZE 3
|
||||
@ -58,7 +59,7 @@ int32_t ctdb_control_register_server_id(struct ctdb_context *ctdb,
|
||||
TDB_DATA indata)
|
||||
{
|
||||
struct ctdb_server_id *server_id;
|
||||
struct ctdb_client *client = ctdb_reqid_find(ctdb, client_id, struct ctdb_client);
|
||||
struct ctdb_client *client = reqid_find(ctdb->idr, client_id, struct ctdb_client);
|
||||
|
||||
|
||||
if (client == NULL) {
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "system/wait.h"
|
||||
#include "../include/ctdb_private.h"
|
||||
#include "../common/rb_tree.h"
|
||||
#include "common/reqid.h"
|
||||
|
||||
|
||||
#define TAKEOVER_TIMEOUT() timeval_current_ofs(ctdb->tunable.takeover_timeout,0)
|
||||
@ -820,9 +821,9 @@ static void release_kill_clients(struct ctdb_context *ctdb, ctdb_sock_addr *addr
|
||||
ctdb_addr_to_str(&ip->addr)));
|
||||
|
||||
if (ctdb_same_ip(&tmp_addr, addr)) {
|
||||
struct ctdb_client *client = ctdb_reqid_find(ctdb,
|
||||
ip->client_id,
|
||||
struct ctdb_client);
|
||||
struct ctdb_client *client = reqid_find(ctdb->idr,
|
||||
ip->client_id,
|
||||
struct ctdb_client);
|
||||
DEBUG(DEBUG_INFO,("matched client %u with IP %s and pid %u\n",
|
||||
ip->client_id,
|
||||
ctdb_addr_to_str(&ip->addr),
|
||||
@ -2799,7 +2800,7 @@ static int ctdb_client_ip_destructor(struct ctdb_client_ip *ip)
|
||||
int32_t ctdb_control_tcp_client(struct ctdb_context *ctdb, uint32_t client_id,
|
||||
TDB_DATA indata)
|
||||
{
|
||||
struct ctdb_client *client = ctdb_reqid_find(ctdb, client_id, struct ctdb_client);
|
||||
struct ctdb_client *client = reqid_find(ctdb->idr, client_id, struct ctdb_client);
|
||||
struct ctdb_control_tcp_addr *tcp_sock = NULL;
|
||||
struct ctdb_tcp_list *tcp;
|
||||
struct ctdb_tcp_connection t;
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "tdb.h"
|
||||
#include "../include/ctdb_private.h"
|
||||
#include "lib/util/dlinklist.h"
|
||||
#include "common/reqid.h"
|
||||
|
||||
typedef void (*ctdb_traverse_fn_t)(void *private_data, TDB_DATA key, TDB_DATA data);
|
||||
|
||||
@ -286,7 +287,7 @@ struct ctdb_traverse_all_handle {
|
||||
*/
|
||||
static int ctdb_traverse_all_destructor(struct ctdb_traverse_all_handle *state)
|
||||
{
|
||||
ctdb_reqid_remove(state->ctdb, state->reqid);
|
||||
reqid_remove(state->ctdb->idr, state->reqid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -360,7 +361,7 @@ static struct ctdb_traverse_all_handle *ctdb_daemon_traverse_all(struct ctdb_db_
|
||||
|
||||
state->ctdb = ctdb;
|
||||
state->ctdb_db = ctdb_db;
|
||||
state->reqid = ctdb_reqid_new(ctdb_db->ctdb, state);
|
||||
state->reqid = reqid_new(ctdb_db->ctdb->idr, state);
|
||||
state->callback = callback;
|
||||
state->private_data = start_state;
|
||||
state->null_count = 0;
|
||||
@ -574,7 +575,7 @@ int32_t ctdb_control_traverse_data(struct ctdb_context *ctdb, TDB_DATA data, TDB
|
||||
return -1;
|
||||
}
|
||||
|
||||
state = ctdb_reqid_find(ctdb, d->reqid, struct ctdb_traverse_all_handle);
|
||||
state = reqid_find(ctdb->idr, d->reqid, struct ctdb_traverse_all_handle);
|
||||
if (state == NULL || d->reqid != state->reqid) {
|
||||
/* traverse might have been terminated already */
|
||||
return -1;
|
||||
@ -707,7 +708,7 @@ int32_t ctdb_control_traverse_start_ext(struct ctdb_context *ctdb,
|
||||
struct ctdb_traverse_start_ext *d = (struct ctdb_traverse_start_ext *)data.dptr;
|
||||
struct traverse_start_state *state;
|
||||
struct ctdb_db_context *ctdb_db;
|
||||
struct ctdb_client *client = ctdb_reqid_find(ctdb, client_id, struct ctdb_client);
|
||||
struct ctdb_client *client = reqid_find(ctdb->idr, client_id, struct ctdb_client);
|
||||
|
||||
if (client == NULL) {
|
||||
DEBUG(DEBUG_ERR,(__location__ " No client found\n"));
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "system/network.h"
|
||||
#include "cmdline.h"
|
||||
#include "../include/ctdb_private.h"
|
||||
#include "common/reqid.h"
|
||||
|
||||
static struct {
|
||||
const char *nlist;
|
||||
@ -185,9 +186,14 @@ int main(int argc, const char *argv[])
|
||||
ctdb->recovery_mode = CTDB_RECOVERY_NORMAL;
|
||||
ctdb->recovery_master = (uint32_t)-1;
|
||||
ctdb->upcalls = &ctdb_upcalls;
|
||||
ctdb->idr = idr_init(ctdb);
|
||||
ctdb->recovery_lock_fd = -1;
|
||||
|
||||
ret = reqid_init(ctdb, 0, &ctdb->idr);;
|
||||
if (ret != 0) {
|
||||
DEBUG(DEBUG_ALERT, ("reqid_init failed (%s)\n", strerror(ret)));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ctdb_tunables_set_defaults(ctdb);
|
||||
|
||||
ret = ctdb_set_recovery_lock_file(ctdb, options.recovery_lock_file);
|
||||
|
@ -179,6 +179,7 @@ ctdb_get_capabilities(struct ctdb_context *ctdb,
|
||||
#include "common/ctdb_logging.c"
|
||||
#include "common/ctdb_fork.c"
|
||||
#include "common/system_util.c"
|
||||
#include "common/reqid.c"
|
||||
|
||||
/* CTDB_CLIENT_OBJ */
|
||||
#include "client/ctdb_client.c"
|
||||
|
@ -42,6 +42,7 @@ bool fast_start;
|
||||
#include "common/ctdb_logging.c"
|
||||
#include "common/ctdb_fork.c"
|
||||
#include "common/system_util.c"
|
||||
#include "common/reqid.c"
|
||||
|
||||
/* CTDB_SERVER_OBJ */
|
||||
#include "server/ctdb_daemon.c"
|
||||
|
Loading…
Reference in New Issue
Block a user