mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
2 bugfixes
- ibw_stop handling - ibw_send: < instead of <= (This used to be ctdb commit 4774ef7e9e33f26745346b9bfe445d913f196e81)
This commit is contained in:
parent
a9a03b6c00
commit
36d53e5043
@ -476,21 +476,10 @@ static void ibw_event_handler_cm(struct event_context *ev,
|
||||
|
||||
case RDMA_CM_EVENT_DISCONNECTED:
|
||||
if (cma_id!=pctx->cm_id) {
|
||||
DEBUG(0, ("client DISCONNECT event\n"));
|
||||
DEBUG(0, ("client DISCONNECT event cm_id=%p\n", cma_id));
|
||||
conn = talloc_get_type(cma_id->context, struct ibw_conn);
|
||||
conn->state = IBWC_DISCONNECTED;
|
||||
pctx->connstate_func(NULL, conn);
|
||||
|
||||
talloc_free(conn);
|
||||
|
||||
/* if we are the last... */
|
||||
if (ctx->conn_list==NULL)
|
||||
rdma_disconnect(pctx->cm_id);
|
||||
} else {
|
||||
DEBUG(0, ("server DISCONNECT event\n"));
|
||||
ctx->state = IBWS_STOPPED; /* ??? TODO: try it... */
|
||||
/* talloc_free(ctx) should be called within or after this func */
|
||||
pctx->connstate_func(ctx, NULL);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -894,9 +883,11 @@ cleanup:
|
||||
|
||||
int ibw_stop(struct ibw_ctx *ctx)
|
||||
{
|
||||
struct ibw_ctx_priv *pctx = (struct ibw_ctx_priv *)ctx->internal;
|
||||
struct ibw_conn *p;
|
||||
|
||||
DEBUG(10, ("ibw_stop\n"));
|
||||
|
||||
for(p=ctx->conn_list; p!=NULL; p=p->next) {
|
||||
if (ctx->state==IBWC_ERROR || ctx->state==IBWC_CONNECTED) {
|
||||
if (ibw_disconnect(p))
|
||||
@ -904,6 +895,9 @@ int ibw_stop(struct ibw_ctx *ctx)
|
||||
}
|
||||
}
|
||||
|
||||
ctx->state = IBWS_STOPPED;
|
||||
pctx->connstate_func(ctx, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1003,20 +997,17 @@ int ibw_connect(struct ibw_ctx *ctx, struct sockaddr_in *serv_addr, void *conn_u
|
||||
int ibw_disconnect(struct ibw_conn *conn)
|
||||
{
|
||||
int rc;
|
||||
struct ibw_ctx_priv *pctx = talloc_get_type(conn->ctx->internal, struct ibw_ctx_priv);
|
||||
struct ibw_conn_priv *pconn = talloc_get_type(conn->internal, struct ibw_conn_priv);
|
||||
|
||||
DEBUG(10, ("ibw_disconnect: cmid=%p\n", pconn->cm_id));
|
||||
|
||||
rc = rdma_disconnect(pctx->cm_id);
|
||||
rc = rdma_disconnect(pconn->cm_id);
|
||||
if (rc) {
|
||||
sprintf(ibw_lasterr, "ibw_disconnect failed with %d", rc);
|
||||
DEBUG(0, (ibw_lasterr));
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* continued at RDMA_CM_EVENT_DISCONNECTED */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1092,7 +1083,7 @@ int ibw_send(struct ibw_conn *conn, void *buf, void *key, uint32_t len)
|
||||
*((uint32_t *)buf) = htonl(len);
|
||||
|
||||
/* can we send it right now? */
|
||||
if (pconn->wr_sent<=pctx->opts.max_send_wr) {
|
||||
if (pconn->wr_sent<pctx->opts.max_send_wr) {
|
||||
struct ibv_sge list = {
|
||||
.addr = (uintptr_t) NULL,
|
||||
.length = len,
|
||||
|
@ -59,6 +59,7 @@ struct ibwtest_ctx {
|
||||
int nmsg; /* number of messages to send (client) */
|
||||
|
||||
int kill_me;
|
||||
int stopping;
|
||||
int error;
|
||||
struct ibw_ctx *ibwctx;
|
||||
|
||||
@ -187,8 +188,6 @@ int ibwtest_connstate_handler(struct ibw_ctx *ctx, struct ibw_conn *conn)
|
||||
break;
|
||||
case IBWS_STOPPED:
|
||||
DEBUG(10, ("test IBWS_STOPPED\n"));
|
||||
talloc_free(tcx->ibwctx);
|
||||
DEBUG(10, ("talloc_free(tcx->ibwctx) DONE\n"));
|
||||
tcx->kill_me = 1; /* main loop can exit */
|
||||
break;
|
||||
case IBWS_ERROR:
|
||||
@ -263,8 +262,10 @@ int ibwtest_receive_handler(struct ibw_conn *conn, void *buf, int n)
|
||||
char msg[26];
|
||||
sprintf(msg, "hello world %d", tcx->nmsg--);
|
||||
tcx->error = ibwtest_send_test_msg(tcx, conn, msg);
|
||||
if (tcx->nmsg==0)
|
||||
tcx->kill_me = 1;
|
||||
if (tcx->nmsg==0) {
|
||||
ibw_stop(tcx->ibwctx);
|
||||
tcx->stopping = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -294,11 +295,18 @@ void ibwtest_timeout_handler(struct event_context *ev, struct timed_event *te,
|
||||
|
||||
static struct ibwtest_ctx *testctx = NULL;
|
||||
|
||||
void ibwtest_sigquit_handler(int sig)
|
||||
void ibwtest_sigint_handler(int sig)
|
||||
{
|
||||
DEBUG(0, ("got SIGQUIT\n"));
|
||||
if (testctx)
|
||||
DEBUG(0, ("got SIGINT\n"));
|
||||
if (testctx) {
|
||||
if (testctx->stopping) {
|
||||
DEBUG(10, ("forcing exit...\n"));
|
||||
testctx->kill_me = 1;
|
||||
} else {
|
||||
ibw_stop(testctx->ibwctx);
|
||||
testctx->stopping = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int ibwtest_parse_attrs(struct ibwtest_ctx *tcx, char *optext,
|
||||
@ -418,7 +426,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* here is the only case we can't avoid using global... */
|
||||
testctx = tcx;
|
||||
signal(SIGQUIT, ibwtest_sigquit_handler);
|
||||
signal(SIGINT, ibwtest_sigint_handler);
|
||||
|
||||
while ((op=getopt(argc, argv, "i:o:d:m:st:n:l:")) != -1) {
|
||||
switch (op) {
|
||||
|
Loading…
Reference in New Issue
Block a user