예제 #1
0
/*---------------------------------------------------------------------------*/
static int on_request(struct xio_session *session,
			struct xio_msg *req,
			int more_in_batch,
			void *cb_user_context)
{
	struct thread_data	*tdata = cb_user_context;
	int i = req->sn % QUEUE_DEPTH;

	/* process request */
	process_request(tdata, req);

	/* attach request to response */
	tdata->rsp[i].request = req;

	xio_send_response(&tdata->rsp[i]);
	tdata->nsent++;

#if  TEST_DISCONNECT
	if (tdata->nsent == DISCONNECT_NR) {
		struct xio_connection *connection =
			xio_get_connection(session,tdata->ctx);
		xio_disconnect(connection);
		return 0;
	}
#endif

	return 0;
}
예제 #2
0
/*---------------------------------------------------------------------------*/
static int on_new_session(struct xio_session *session,
			struct xio_new_session_req *session_data,
			void *cb_prv_data)
{
	struct xio_msg	*req;
	int		i = 0;

	printf("**** [%p] on_new_session :%s:%d\n", session,
	       get_ip((struct sockaddr *)&session_data->src_addr),
	       get_port((struct sockaddr *)&session_data->src_addr));

	xio_accept(session, NULL, 0, NULL, 0);

	msg_pool_reset(pool);
	conn = xio_get_connection(session, ctx);

	printf("**** starting ...\n");
	while (1) {
		/* create transaction */
		req = msg_pool_get(pool);
		if (req == NULL)
			break;

		/* get pointers to internal buffers */
		req->in.header.iov_base = NULL;
		req->in.header.iov_len = 0;
		req->in.data_iovlen = 1;
		req->in.data_iov[0].iov_base = NULL;
		req->in.data_iov[0].iov_len  = ONE_MB;
		req->in.data_iov[0].mr = NULL;

		/* recycle the message and fill new request */
		msg_set(req, 1,
			test_config.hdr_len,
			test_config.data_len);

		/* try to send it */
		if (xio_send_request(conn, req) == -1) {
			printf("**** sent %d messages\n", i);
			if (xio_errno() != EAGAIN)
				printf("**** [%p] Error - xio_send_msg " \
				       "failed. %s\n",
					session,
					xio_strerror(xio_errno()));
			msg_pool_put(pool, req);
			return 0;
		}
		i++;
		if (i == 256)
			break;
	}

	return 0;
}
예제 #3
0
/*---------------------------------------------------------------------------*/
static int on_new_session(struct xio_session *session,
                          struct xio_new_session_req *req,
                          void *cb_user_context)
{
    int			i = 0;
    struct ow_test_params	*ow_params = cb_user_context;
    struct xio_msg		*msg;

    printf("**** [%p] on_new_session :%s:%d\n", session,
           get_ip((struct sockaddr *)&req->src_addr),
           get_port((struct sockaddr *)&req->src_addr));

    xio_accept(session, NULL, 0, NULL, 0);

    if (ow_params->connection == NULL)
        ow_params->connection = xio_get_connection(session,
                                ow_params->ctx);

    for (i = 0; i < MAX_OUTSTANDING_REQS; i++) {
        /* pick message from the pool */
        msg = msg_pool_get(ow_params->pool);
        if (msg == NULL)
            break;

        /* assign buffers to the message */
        msg_write(&ow_params->msg_params, msg,
                  NULL, test_config.hdr_len,
                  NULL, test_config.data_len);

        /* ask for read receipt since the message needed to be
         * recycled to the pool */
        msg->flags = XIO_MSG_FLAG_REQUEST_READ_RECEIPT;

        /* send the message */
        if (xio_send_msg(ow_params->connection, msg) == -1) {
            printf("**** sent %d messages\n", i);
            if (xio_errno() != EAGAIN)
                printf("**** [%p] Error - xio_send_msg " \
                       "failed. %s\n",
                       session,
                       xio_strerror(xio_errno()));
            msg_pool_put(ow_params->pool, msg);
            return 0;
        }
        ow_params->nsent++;
    }
    return 0;
}
예제 #4
0
/*---------------------------------------------------------------------------*/
static int on_new_session(struct xio_session *session,
			  struct xio_new_session_req *req,
			  void *cb_user_context)
{
	struct test_params *test_params = cb_user_context;

	printf("**** [%p] on_new_session :%s:%d\n", session,
	       get_ip((struct sockaddr *)&req->src_addr),
	       get_port((struct sockaddr *)&req->src_addr));

	xio_accept(session, NULL, 0, NULL, 0);

	if (test_params->connection == NULL)
		test_params->connection = xio_get_connection(session,
							     test_params->ctx);


	return 0;
}