1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

LibCTDB : add support for getrecmode

(This used to be ctdb commit 0893fa0f3257f50d54896ffa78ec12ee11e8c6d2)
This commit is contained in:
Ronnie Sahlberg 2011-08-23 15:00:27 +10:00
parent 9729d3e339
commit 5e72ee5127
3 changed files with 95 additions and 0 deletions

View File

@ -551,6 +551,35 @@ bool ctdb_getrecmaster_recv(struct ctdb_connection *ctdb,
struct ctdb_request *handle,
uint32_t *recmaster);
/**
* ctdb_getrecmode_send - read the recovery mode of a node
* @ctdb: the ctdb_connection from ctdb_connect.
* @destnode: the destination node (see below)
* @callback: the callback when ctdb replies to our message (typesafe)
* @cbdata: the argument to callback()
*
* There are several special values for destnode, detailed in
* ctdb_protocol.h, particularly CTDB_CURRENT_NODE which means the
* local ctdbd.
*/
struct ctdb_request *
ctdb_getrecmode_send(struct ctdb_connection *ctdb,
uint32_t destnode,
ctdb_callback_t callback, void *cbdata);
/**
* ctdb_getrecmode_recv - read an ctdb_getrecmode reply from ctdbd
* @ctdb: the ctdb_connection from ctdb_connect.
* @req: the completed request.
* @recmode: a pointer to the recmode to fill in
*
* This returns false if something went wrong, or otherwise fills in
* recmode.
*/
bool ctdb_getrecmode_recv(struct ctdb_connection *ctdb,
struct ctdb_request *handle,
uint32_t *recmode);
/**
* ctdb_cancel - cancel an uncompleted request
* @ctdb: the ctdb_connection from ctdb_connect.
@ -668,6 +697,23 @@ bool ctdb_getrecmaster(struct ctdb_connection *ctdb,
uint32_t *recmaster);
/**
* ctdb_getrecmode - read the recovery mode of a node (synchronous)
* @ctdb: the ctdb_connection from ctdb_connect.
* @destnode: the destination node (see below)
* @recmode: a pointer to the recmode to fill in
*
* There are several special values for destnode, detailed in
* ctdb_protocol.h, particularly CTDB_CURRENT_NODE which means the
* local ctdbd.
*
* Returns true and fills in *recmode on success.
*/
bool ctdb_getrecmode(struct ctdb_connection *ctdb,
uint32_t destnode,
uint32_t *recmode);
/**
* ctdb_getnodemap - read the nodemap from a node (synchronous)
* @ctdb: the ctdb_connection from ctdb_connect.
@ -775,6 +821,10 @@ void ctdb_free_publicips(struct ctdb_all_public_ips *ips);
ctdb_getrecmaster_send((ctdb), (destnode), \
ctdb_sendcb((cb), (cbdata)), (cbdata))
#define ctdb_getrecmode_send(ctdb, destnode, cb, cbdata) \
ctdb_getrecmode_send((ctdb), (destnode), \
ctdb_sendcb((cb), (cbdata)), (cbdata))
#define ctdb_getnodemap_send(ctdb, destnode, cb, cbdata) \
ctdb_getnodemap_send((ctdb), (destnode), \
ctdb_sendcb((cb), (cbdata)), (cbdata))

View File

@ -23,6 +23,7 @@
/* Remove type-safety macros. */
#undef ctdb_getrecmaster_send
#undef ctdb_getrecmode_send
#undef ctdb_getpnn_send
#undef ctdb_getnodemap_send
#undef ctdb_getpublicips_send
@ -54,6 +55,33 @@ struct ctdb_request *ctdb_getrecmaster_send(struct ctdb_connection *ctdb,
callback, private_data);
}
bool ctdb_getrecmode_recv(struct ctdb_connection *ctdb,
struct ctdb_request *req, uint32_t *recmode)
{
struct ctdb_reply_control *reply;
reply = unpack_reply_control(req, CTDB_CONTROL_GET_RECMODE);
if (!reply) {
return false;
}
if (reply->status == -1) {
DEBUG(ctdb, LOG_ERR, "ctdb_getrecmode_recv: status -1");
return false;
}
*recmode = reply->status;
return true;
}
struct ctdb_request *ctdb_getrecmode_send(struct ctdb_connection *ctdb,
uint32_t destnode,
ctdb_callback_t callback,
void *private_data)
{
return new_ctdb_control_request(ctdb, CTDB_CONTROL_GET_RECMODE,
destnode, NULL, 0,
callback, private_data);
}
bool ctdb_getpnn_recv(struct ctdb_connection *ctdb,
struct ctdb_request *req, uint32_t *pnn)
{

View File

@ -83,6 +83,23 @@ bool ctdb_getrecmaster(struct ctdb_connection *ctdb,
return ret;
}
bool ctdb_getrecmode(struct ctdb_connection *ctdb,
uint32_t destnode, uint32_t *recmode)
{
struct ctdb_request *req;
bool done = false;
bool ret = false;
req = synchronous(ctdb,
ctdb_getrecmode_send(ctdb, destnode, set, &done),
&done);
if (req != NULL) {
ret = ctdb_getrecmode_recv(ctdb, req, recmode);
ctdb_request_free(req);
}
return ret;
}
struct ctdb_db *ctdb_attachdb(struct ctdb_connection *ctdb,
const char *name, bool persistent,
uint32_t tdb_flags)