void xio_buf_free(struct perf_buf *pbuf) { if (pbuf->mr) xio_dereg_mr(&pbuf->mr); if (pbuf->addr) free_mem_buf(pbuf->addr, pbuf->shmid); free(pbuf); }
/*---------------------------------------------------------------------------*/ static void *portal_server_cb(void *data) { struct thread_data *tdata = data; cpu_set_t cpuset; struct xio_server *server; int retval = 0; /* set affinity to thread */ CPU_ZERO(&cpuset); CPU_SET(tdata->affinity, &cpuset); pthread_setaffinity_np(tdata->thread_id, sizeof(cpu_set_t), &cpuset); /* prepare data for the cuurent thread */ tdata->pool = msg_pool_alloc(tdata->user_param->queue_depth + 64); /* create thread context for the client */ tdata->ctx = xio_context_create(NULL, tdata->user_param->poll_timeout, tdata->affinity); /* bind a listener server to a portal/url */ server = xio_bind(tdata->ctx, &portal_server_ops, tdata->user_param->portals_arr[tdata->portal_index], NULL, 0, tdata); if (server == NULL) goto cleanup; /* the default xio supplied main loop */ xio_context_run_loop(tdata->ctx, XIO_INFINITE); /* detach the server */ xio_unbind(server); if (tdata->pool) msg_pool_free(tdata->pool); if (tdata->mr) xio_dereg_mr(&tdata->mr); if (tdata->buf) free(tdata->buf); if (tdata->out_xbuf) xio_free(&tdata->out_xbuf); if (tdata->in_xbuf) xio_free(&tdata->in_xbuf); cleanup: /* free the context */ xio_context_destroy(tdata->ctx); pthread_exit(&retval); }
/*---------------------------------------------------------------------------*/ inline void msg_pool_free(struct msg_pool *pool) { if (pool) { if (pool->mr) xio_dereg_mr(&pool->mr); if (pool->data) free_mem_buf(pool->data, pool->shmid); free(pool->header); free(pool); } }
/*---------------------------------------------------------------------------*/ static void *portal_server_cb(void *data) { struct thread_data *tdata = data; cpu_set_t cpuset; struct xio_server *server; int retval = 0; /* set affinity to thread */ CPU_ZERO(&cpuset); CPU_SET(tdata->affinity, &cpuset); pthread_setaffinity_np(tdata->thread_id, sizeof(cpu_set_t), &cpuset); /* prepare data for the cuurent thread */ tdata->pool = msg_pool_alloc(MAX_POOL_SIZE, test_config.hdr_len, test_config.data_len, 0, 0); /* create thread context for the client */ tdata->ctx = xio_context_create(NULL, test_config.poll_timeout); /* bind a listener server to a portal/url */ printf("thread [%d] - listen:%s\n", tdata->affinity, tdata->portal); server = xio_bind(tdata->ctx, &portal_server_ops, tdata->portal, NULL, 0, tdata); if (server == NULL) goto cleanup; /* the default xio supplied main loop */ xio_context_run_loop(tdata->ctx, XIO_INFINITE); /* normal exit phase */ fprintf(stdout, "thread [%d] - exit signaled\n", tdata->affinity); /* detach the server */ xio_unbind(server); if (tdata->pool) msg_pool_free(tdata->pool); if (tdata->mr) xio_dereg_mr(&tdata->mr); if (tdata->buf) free(tdata->buf); cleanup: /* free the context */ xio_context_destroy(tdata->ctx); pthread_exit(&retval); }
/*---------------------------------------------------------------------------*/ void msg_api_free(struct msg_params *msg_params) { if (msg_params->g_hdr) { free(msg_params->g_hdr); msg_params->g_hdr = NULL; } if (msg_params->g_data_mr) { xio_dereg_mr(&msg_params->g_data_mr); msg_params->g_data_mr = NULL; } if (msg_params->g_data) { free_mem_buf(msg_params->g_data, msg_params->g_shmid); msg_params->g_data = NULL; } }
/*---------------------------------------------------------------------------*/ int xio_free(struct xio_buf **buf) { struct xio_mr *tmr = (*buf)->mr; int retval = 0; if ((*buf)->addr) ufree((*buf)->addr); retval = xio_dereg_mr(&tmr); ufree(*buf); *buf = NULL; return retval; }