mirror of
https://github.com/samba-team/samba.git
synced 2025-08-02 00:22:11 +03:00
- ctdb/ib minor bugfixes (error case)
- make ctdb capable of alternative connection (like ib) again, solved the fork problem - do_debug memory overwrite bugfix (occured using ibwrapper_test with wrong address given) (This used to be ctdb commit da0b84cda26d544f63841dfd770ed7ebad401944)
This commit is contained in:
@ -31,22 +31,45 @@
|
|||||||
*/
|
*/
|
||||||
int ctdb_set_transport(struct ctdb_context *ctdb, const char *transport)
|
int ctdb_set_transport(struct ctdb_context *ctdb, const char *transport)
|
||||||
{
|
{
|
||||||
|
ctdb->transport = talloc_strdup(ctdb, transport);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ctdb_init_transport(struct ctdb_context *ctdb)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
int ctdb_tcp_init(struct ctdb_context *ctdb);
|
int ctdb_tcp_init(struct ctdb_context *ctdb);
|
||||||
|
int transport_found = 0;
|
||||||
#ifdef USE_INFINIBAND
|
#ifdef USE_INFINIBAND
|
||||||
int ctdb_ibw_init(struct ctdb_context *ctdb);
|
int ctdb_ibw_init(struct ctdb_context *ctdb);
|
||||||
#endif /* USE_INFINIBAND */
|
#endif /* USE_INFINIBAND */
|
||||||
|
|
||||||
if (strcmp(transport, "tcp") == 0) {
|
if (strcmp(ctdb->transport, "tcp") == 0) {
|
||||||
return ctdb_tcp_init(ctdb);
|
transport_found = 1;
|
||||||
|
if (ctdb_tcp_init(ctdb))
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
#ifdef USE_INFINIBAND
|
#ifdef USE_INFINIBAND
|
||||||
if (strcmp(transport, "ib") == 0) {
|
else if (strcmp(ctdb->transport, "ib") == 0) {
|
||||||
return ctdb_ibw_init(ctdb);
|
transport_found = 1;
|
||||||
|
if (ctdb_ibw_init(ctdb))
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
#endif /* USE_INFINIBAND */
|
#endif /* USE_INFINIBAND */
|
||||||
|
|
||||||
ctdb_set_error(ctdb, "Unknown transport '%s'\n", transport);
|
if (!transport_found) {
|
||||||
return -1;
|
ctdb_set_error(ctdb, "Unknown transport '%s'\n", ctdb->transport);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(i=0; i<ctdb->num_nodes; i++) {
|
||||||
|
if (ctdb->methods->add_node(ctdb->nodes[i]) != 0) {
|
||||||
|
DEBUG(0, ("methods->add_node failed at %d\n", i));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -116,11 +139,6 @@ static int ctdb_add_node(struct ctdb_context *ctdb, char *nstr)
|
|||||||
will change! */
|
will change! */
|
||||||
node->vnn = ctdb->num_nodes;
|
node->vnn = ctdb->num_nodes;
|
||||||
|
|
||||||
if (ctdb->methods->add_node(node) != 0) {
|
|
||||||
talloc_free(node);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ctdb_same_address(&ctdb->address, &node->address)) {
|
if (ctdb_same_address(&ctdb->address, &node->address)) {
|
||||||
ctdb->vnn = node->vnn;
|
ctdb->vnn = node->vnn;
|
||||||
}
|
}
|
||||||
|
@ -373,7 +373,10 @@ int ctdb_set_message_handler(struct ctdb_context *ctdb, uint32_t srvid,
|
|||||||
|
|
||||||
/* if the domain socket is not yet open, open it */
|
/* if the domain socket is not yet open, open it */
|
||||||
if (ctdb->daemon.sd==-1) {
|
if (ctdb->daemon.sd==-1) {
|
||||||
ux_socket_connect(ctdb);
|
if (ux_socket_connect(ctdb)) {
|
||||||
|
DEBUG(0, ("ux_socket_connect failed\n"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ZERO_STRUCT(c);
|
ZERO_STRUCT(c);
|
||||||
|
@ -44,6 +44,11 @@ static void daemon_incoming_packet(void *, uint8_t *, uint32_t );
|
|||||||
|
|
||||||
static void ctdb_main_loop(struct ctdb_context *ctdb)
|
static void ctdb_main_loop(struct ctdb_context *ctdb)
|
||||||
{
|
{
|
||||||
|
/* we are the dispatcher process now, so start the protocol going */
|
||||||
|
if (ctdb_init_transport(ctdb)) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
ctdb->methods->start(ctdb);
|
ctdb->methods->start(ctdb);
|
||||||
|
|
||||||
/* go into a wait loop to allow other nodes to complete */
|
/* go into a wait loop to allow other nodes to complete */
|
||||||
@ -594,6 +599,12 @@ int ctdb_start(struct ctdb_context *ctdb)
|
|||||||
close(fd[0]);
|
close(fd[0]);
|
||||||
close(ctdb->daemon.sd);
|
close(ctdb->daemon.sd);
|
||||||
ctdb->daemon.sd = -1;
|
ctdb->daemon.sd = -1;
|
||||||
|
|
||||||
|
/* Added because of ctdb->methods->allocate_pkt calls */
|
||||||
|
/* TODO: clean */
|
||||||
|
int ctdb_tcp_init(struct ctdb_context *ctdb);
|
||||||
|
ctdb_tcp_init(ctdb);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -557,17 +557,17 @@ static void ibw_event_handler_cm(struct event_context *ev,
|
|||||||
return;
|
return;
|
||||||
error:
|
error:
|
||||||
if (event!=NULL && (rc=rdma_ack_cm_event(event))) {
|
if (event!=NULL && (rc=rdma_ack_cm_event(event))) {
|
||||||
sprintf(ibw_lasterr, "rdma_ack_cm_event failed with %d\n", rc);
|
DEBUG(0, ("rdma_ack_cm_event failed with %d\n", rc));
|
||||||
goto error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG(0, ("cm event handler: %s", ibw_lasterr));
|
DEBUG(0, ("cm event handler: %s", ibw_lasterr));
|
||||||
|
|
||||||
if (cma_id!=pctx->cm_id) {
|
if (cma_id!=pctx->cm_id) {
|
||||||
conn = talloc_get_type(cma_id->context, struct ibw_conn);
|
conn = talloc_get_type(cma_id->context, struct ibw_conn);
|
||||||
if (conn)
|
if (conn) {
|
||||||
conn->state = IBWC_ERROR;
|
conn->state = IBWC_ERROR;
|
||||||
pctx->connstate_func(NULL, conn);
|
pctx->connstate_func(NULL, conn);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ctx->state = IBWS_ERROR;
|
ctx->state = IBWS_ERROR;
|
||||||
pctx->connstate_func(ctx, NULL);
|
pctx->connstate_func(ctx, NULL);
|
||||||
|
@ -70,6 +70,12 @@ struct ctdb_context *ctdb_init(struct event_context *ev);
|
|||||||
*/
|
*/
|
||||||
int ctdb_set_transport(struct ctdb_context *ctdb, const char *transport);
|
int ctdb_set_transport(struct ctdb_context *ctdb, const char *transport);
|
||||||
|
|
||||||
|
/*
|
||||||
|
initialize the chosen transport
|
||||||
|
do this in the process where it is going to be used
|
||||||
|
*/
|
||||||
|
int ctdb_init_transport(struct ctdb_context *ctdb);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
set the directory for the local databases
|
set the directory for the local databases
|
||||||
*/
|
*/
|
||||||
|
@ -120,6 +120,7 @@ struct ctdb_context {
|
|||||||
struct ctdb_address address;
|
struct ctdb_address address;
|
||||||
const char *name;
|
const char *name;
|
||||||
const char *db_directory;
|
const char *db_directory;
|
||||||
|
char *transport;
|
||||||
uint32_t vnn; /* our own vnn */
|
uint32_t vnn; /* our own vnn */
|
||||||
uint32_t num_nodes;
|
uint32_t num_nodes;
|
||||||
uint32_t num_connected;
|
uint32_t num_connected;
|
||||||
@ -362,6 +363,11 @@ int ctdbd_start(struct ctdb_context *ctdb);
|
|||||||
struct ctdb_call_state *ctdbd_call_send(struct ctdb_db_context *ctdb_db, struct ctdb_call *call);
|
struct ctdb_call_state *ctdbd_call_send(struct ctdb_db_context *ctdb_db, struct ctdb_call *call);
|
||||||
int ctdbd_call_recv(struct ctdb_call_state *state, struct ctdb_call *call);
|
int ctdbd_call_recv(struct ctdb_call_state *state, struct ctdb_call *call);
|
||||||
|
|
||||||
|
/*
|
||||||
|
allocate a packet for sending via queue
|
||||||
|
*/
|
||||||
|
void *ctdb_queue_allocate_pkt(TALLOC_CTX *mem_ctx, size_t size);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
queue a packet for sending
|
queue a packet for sending
|
||||||
*/
|
*/
|
||||||
|
@ -22,6 +22,22 @@
|
|||||||
#include "system/time.h"
|
#include "system/time.h"
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
static int vasprintf2(char **ptr, const char *format, va_list ap)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
va_list tmp_ap;
|
||||||
|
|
||||||
|
va_copy(tmp_ap, ap);
|
||||||
|
ret = vsnprintf(NULL, 0, format, tmp_ap);
|
||||||
|
if (ret <= 0) return ret;
|
||||||
|
|
||||||
|
(*ptr) = (char *)malloc(ret+1);
|
||||||
|
if (!*ptr) return -1;
|
||||||
|
ret = vsnprintf(*ptr, ret+1, format, ap);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
void do_debug(const char *format, ...)
|
void do_debug(const char *format, ...)
|
||||||
{
|
{
|
||||||
struct timeval tm;
|
struct timeval tm;
|
||||||
@ -29,7 +45,7 @@ void do_debug(const char *format, ...)
|
|||||||
char *s = NULL;
|
char *s = NULL;
|
||||||
|
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
vasprintf(&s, format, ap);
|
vasprintf2(&s, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
gettimeofday(&tm, NULL);
|
gettimeofday(&tm, NULL);
|
||||||
|
@ -204,7 +204,8 @@ int main(int argc, const char *argv[])
|
|||||||
/* start the protocol running */
|
/* start the protocol running */
|
||||||
ret = ctdb_start(ctdb);
|
ret = ctdb_start(ctdb);
|
||||||
|
|
||||||
ctdb_set_message_handler(ctdb, 0, ring_message_handler,&msg_count);
|
if (ctdb_set_message_handler(ctdb, 0, ring_message_handler,&msg_count))
|
||||||
|
goto error;
|
||||||
|
|
||||||
/* wait until all nodes are connected (should not be needed
|
/* wait until all nodes are connected (should not be needed
|
||||||
outside of test code) */
|
outside of test code) */
|
||||||
@ -212,6 +213,7 @@ int main(int argc, const char *argv[])
|
|||||||
|
|
||||||
bench_ring(ctdb, ev);
|
bench_ring(ctdb, ev);
|
||||||
|
|
||||||
|
error:
|
||||||
/* shut it down */
|
/* shut it down */
|
||||||
ctdb_shutdown(ctdb);
|
ctdb_shutdown(ctdb);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user