/*---------------------------------------------------------------------------*/ static int on_session_event(struct xio_session *session, struct xio_session_event_data *event_data, void *cb_user_context) { /*struct xio_connection_attr conn_attr;*/ pr_info("session event: %s. session:%p, connection:%p, reason: %s\n", xio_session_event_str(event_data->event), session, event_data->conn, xio_strerror(event_data->reason)); switch (event_data->event) { case XIO_SESSION_NEW_CONNECTION_EVENT: if (!test_params.connection) test_params.connection = event_data->conn; break; case XIO_SESSION_CONNECTION_TEARDOWN_EVENT: if (event_data->reason != XIO_E_SESSION_REJECTED) test_params.connection = NULL; xio_connection_destroy(event_data->conn); break; case XIO_SESSION_TEARDOWN_EVENT: xio_session_destroy(session); if (event_data->reason != XIO_E_SESSION_REJECTED) xio_context_stop_loop(test_params.ctx); break; default: break; }; return 0; }
static void xio_module_down(void *data) { struct session_data *session_data; struct xio_session *session; struct xio_connection *connection; session_data = (struct session_data *)data; if (!session_data->session) goto stop_loop_now; if (!session_data->connection) goto destroy_session; connection = session_data->connection; session_data->connection = NULL; xio_connection_destroy(connection); return; destroy_session: /* in multi thread version on need to user reference count */ session = session_data->session; session_data->session = NULL; xio_session_destroy(session); stop_loop_now: /* No session -> no XIO_SESSION_TEARDOWN_EVENT */ xio_context_stop_loop(session_data->ctx); /* exit */ }
/*---------------------------------------------------------------------------*/ static int on_session_event(struct xio_session *session, struct xio_session_event_data *event_data, void *cb_user_context) { struct server_data *server_data = (struct server_data *)cb_user_context; printf("session event: %s. session:%p, connection:%p, reason: %s\n", xio_session_event_str(event_data->event), session, event_data->conn, xio_strerror(event_data->reason)); switch (event_data->event) { case XIO_SESSION_NEW_CONNECTION_EVENT: server_data->connection = event_data->conn; break; case XIO_SESSION_CONNECTION_TEARDOWN_EVENT: xio_connection_destroy(event_data->conn); server_data->connection = NULL; break; case XIO_SESSION_TEARDOWN_EVENT: xio_session_destroy(session); xio_context_stop_loop(server_data->ctx); /* exit */ break; default: break; }; return 0; }
/*---------------------------------------------------------------------------*/ static int on_session_event(struct xio_session *session, struct xio_session_event_data *event_data, void *cb_user_context) { struct ow_test_params *ow_params = cb_user_context; printf("session event: %s. session:%p, connection:%p, reason: %s\n", xio_session_event_str(event_data->event), session, event_data->conn, xio_strerror(event_data->reason)); switch (event_data->event) { case XIO_SESSION_CONNECTION_TEARDOWN_EVENT: xio_connection_destroy(event_data->conn); ow_params->connection = NULL; break; case XIO_SESSION_TEARDOWN_EVENT: process_request(NULL); xio_session_destroy(session); xio_context_stop_loop(ow_params->ctx, 0); break; default: break; }; return 0; }
int xio_exec_req(const struct node_id *nid, struct sd_req *hdr, void *data, bool (*need_retry)(uint32_t epoch), uint32_t epoch, uint32_t max_count) { struct xio_context *ctx = xio_context_create(NULL, 0, -1); struct client_data cli = { .ctx = ctx }; struct xio_connection *conn = sd_xio_create_connection(ctx, nid, &cli); struct xio_msg xreq; struct sd_rsp rsp; sd_assert(!is_main_thread()); memset(&rsp, 0, sizeof(rsp)); memset(&xreq, 0, sizeof(xreq)); client_msg_vec_init(&xreq); memset(&rsp, 0, sizeof(rsp)); msg_prep_for_send(hdr, &rsp, data, &xreq); xio_send_request(conn, &xreq); xio_context_run_loop(ctx, XIO_INFINITE); msg_finalize(hdr, data, cli.rsp); xio_connection_destroy(conn); xio_context_destroy(ctx); return 0; }
/*---------------------------------------------------------------------------*/ static int on_session_event(struct xio_session *session, struct xio_session_event_data *event_data, void *cb_user_context) { struct session_data *session_data = cb_user_context; int i; switch (event_data->event) { case XIO_SESSION_CONNECTION_ERROR_EVENT: case XIO_SESSION_REJECT_EVENT: case XIO_SESSION_CONNECTION_DISCONNECTED_EVENT: fprintf(stderr, "%s. reason: %s\n", xio_session_event_str(event_data->event), xio_strerror(event_data->reason)); for (i = 0; i < threads_iter; i++) { session_data->tdata[i].disconnect = 1; session_data->abort = 1; } break; case XIO_SESSION_CONNECTION_TEARDOWN_EVENT: xio_connection_destroy(event_data->conn); break; case XIO_SESSION_TEARDOWN_EVENT: for (i = 0; i < threads_iter; i++) xio_context_stop_loop(session_data->tdata[i].ctx, 0); break; default: break; }; return 0; }
/*---------------------------------------------------------------------------*/ static int on_session_event(struct xio_session *session, struct xio_session_event_data *event_data, void *cb_user_context) { struct server_data *server_data = cb_user_context; int i; printf("session event: %s. session:%p, connection:%p, reason: %s\n", xio_session_event_str(event_data->event), session, event_data->conn, xio_strerror(event_data->reason)); switch (event_data->event) { case XIO_SESSION_CONNECTION_TEARDOWN_EVENT: xio_connection_destroy(event_data->conn); break; case XIO_SESSION_TEARDOWN_EVENT: xio_session_destroy(session); for (i = 0; i < MAX_THREADS; i++) xio_context_stop_loop(server_data->tdata[i].ctx, 0); xio_context_stop_loop(server_data->ctx, 0); break; default: break; }; return 0; }
/*---------------------------------------------------------------------------*/ static int on_session_event(struct xio_session *session, struct xio_session_event_data *event_data, void *cb_user_context) { struct session_data *session_data = (struct session_data *) cb_user_context; logit(LOG_INFO, "session event: %s. reason: %s\n", xio_session_event_str(event_data->event), xio_strerror(event_data->reason)); switch (event_data->event) { case XIO_SESSION_CONNECTION_DISCONNECTED_EVENT: case XIO_SESSION_CONNECTION_REFUSED_EVENT: reconnect_flag = 1; break; case XIO_SESSION_CONNECTION_ESTABLISHED_EVENT: on_connection_established(event_data->conn, session_data); break; case XIO_SESSION_CONNECTION_TEARDOWN_EVENT: xio_connection_destroy(event_data->conn); session_data->conn = NULL; break; case XIO_SESSION_TEARDOWN_EVENT: xio_session_destroy(session); xio_context_stop_loop(session_data->ctx); /* exit */ break; default: break; }; return 0; }
/*---------------------------------------------------------------------------*/ static int on_session_event(struct xio_session *session, struct xio_session_event_data *event_data, void *cb_prv_data) { printf("session event: %s. session:%p, connection:%p, reason: %s\n", xio_session_event_str(event_data->event), session, event_data->conn, xio_strerror(event_data->reason)); switch (event_data->event) { case XIO_SESSION_CONNECTION_TEARDOWN_EVENT: xio_connection_destroy(event_data->conn); break; case XIO_SESSION_TEARDOWN_EVENT: process_request(NULL); xio_session_destroy(session); if (test_config.finite_run) xio_context_stop_loop(ctx); /* exit */ break; default: break; }; return 0; }
/*---------------------------------------------------------------------------*/ static int on_session_event(struct xio_session *session, struct xio_session_event_data *event_data, void *cb_user_context) { struct test_params *test_params = (struct test_params *)cb_user_context; printf("session event: %s. reason: %s\n", xio_session_event_str(event_data->event), xio_strerror(event_data->reason)); switch (event_data->event) { case XIO_SESSION_CONNECTION_TEARDOWN_EVENT: printf("nsent:%lu, nrecv:%lu, " \ "delta:%lu\n", test_params->nsent, test_params->nrecv, test_params->nsent-test_params->nrecv); xio_connection_destroy(event_data->conn); break; case XIO_SESSION_REJECT_EVENT: case XIO_SESSION_TEARDOWN_EVENT: xio_context_stop_loop(test_params->ctx); /* exit */ break; default: break; }; return 0; }
/*---------------------------------------------------------------------------*/ static int on_session_event(struct xio_session *session, struct xio_session_event_data *event_data, void *cb_user_context) { struct server_data *server_data = cb_user_context; pr_info("session event: %s. reason: %s\n", xio_session_event_str(event_data->event), xio_strerror(event_data->reason)); switch (event_data->event) { case XIO_SESSION_NEW_CONNECTION_EVENT: server_data->connection = event_data->conn; break; case XIO_SESSION_CONNECTION_TEARDOWN_EVENT: xio_connection_destroy(event_data->conn); server_data->connection = NULL; break; case XIO_SESSION_TEARDOWN_EVENT: server_data->session = NULL; xio_session_destroy(session); if (atomic_read(&module_state) & 0x80) xio_context_stop_loop(server_data->ctx); /* exit */ break; default: break; }; return 0; }
/*---------------------------------------------------------------------------*/ static int on_session_event(struct xio_session *session, struct xio_session_event_data *event_data, void *cb_user_context) { pr_info("session event: %s. reason: %s\n", xio_session_event_str(event_data->event), xio_strerror(event_data->reason)); switch (event_data->event) { case XIO_SESSION_CONNECTION_ESTABLISHED_EVENT: on_connection_established(event_data->conn); break; case XIO_SESSION_CONNECTION_TEARDOWN_EVENT: xio_connection_destroy(event_data->conn); break; case XIO_SESSION_REJECT_EVENT: case XIO_SESSION_TEARDOWN_EVENT: g_session = NULL; xio_session_destroy(session); xio_context_stop_loop(ctx); /* exit */ if (pool) { msg_pool_free(pool); pool = NULL; } break; default: break; }; return 0; }
/*---------------------------------------------------------------------------*/ static int on_session_event(struct xio_session *session, struct xio_session_event_data *event_data, void *cb_user_context) { switch (event_data->event) { case XIO_SESSION_CONNECTION_TEARDOWN_EVENT: xio_connection_destroy(event_data->conn); break; case XIO_SESSION_TEARDOWN_EVENT: xio_session_destroy(session); break; default: break; }; return 0; }
/*---------------------------------------------------------------------------*/ static int on_session_event(struct xio_session *session, struct xio_session_event_data *event_data, void *cb_user_context) { struct xio_connection_attr conn_attr; struct test_params *test_params = cb_user_context; pr_info("session event: %s. session:%p, connection:%p, reason: %s\n", xio_session_event_str(event_data->event), session, event_data->conn, xio_strerror(event_data->reason)); switch (event_data->event) { case XIO_SESSION_NEW_CONNECTION_EVENT: /* assign connection private data */ conn_attr.user_context = cb_user_context; xio_modify_connection(event_data->conn, &conn_attr, XIO_CONNECTION_ATTR_USER_CTX); if (!test_params->connection) test_params->connection = event_data->conn; break; case XIO_SESSION_CONNECTION_TEARDOWN_EVENT: if (event_data->reason != XIO_E_SESSION_REJECTED) { pr_info("last recv:%llu\n", test_params->nrecv); test_params->connection = NULL; } xio_connection_destroy(event_data->conn); test_params->connection = NULL; break; case XIO_SESSION_TEARDOWN_EVENT: test_params->session = NULL; xio_session_destroy(session); if (event_data->reason != XIO_E_SESSION_REJECTED) { if (atomic_read(&module_state) & 0x80) xio_context_stop_loop( test_params->ctx); /* exit */ } break; default: break; }; return 0; }
static int server_on_session_event(struct xio_session *session, struct xio_session_event_data *event_data, void *cb_user_context) { struct client_info *ci; struct xio_connection_attr attr; struct server_data *server_data = (struct server_data *)cb_user_context; sd_debug("session event: %s. session:%p, connection:%p, reason: %s", xio_session_event_str(event_data->event), session, event_data->conn, xio_strerror(event_data->reason)); switch (event_data->event) { case XIO_SESSION_NEW_CONNECTION_EVENT: server_data->nr_conn++; memset(&attr, 0, sizeof(attr)); ci = xio_create_client(session, event_data->conn); list_add_tail(&ci->conn.list, &server_data->conn_list); attr.user_context = ci; xio_modify_connection(event_data->conn, &attr, XIO_CONNECTION_ATTR_USER_CTX); xio_context_stop_loop(xio_get_main_ctx()); break; case XIO_SESSION_CONNECTION_TEARDOWN_EVENT: server_data->nr_conn--; sd_assert(0 <= server_data->nr_conn); xio_connection_destroy(event_data->conn); xio_context_stop_loop(xio_get_main_ctx()); break; case XIO_SESSION_TEARDOWN_EVENT: xio_session_destroy(session); xio_context_stop_loop(xio_get_main_ctx()); break; default: break; }; return 0; }
/*---------------------------------------------------------------------------*/ static int on_session_event(struct xio_session *session, struct xio_session_event_data *event_data, void *cb_user_context) { struct server_data *sdata; struct thread_data *tdata; int i; sdata = (struct server_data *)cb_user_context; tdata = (event_data->conn_user_context == sdata) ? NULL : (struct thread_data *)event_data->conn_user_context; printf("session event: %s. session:%p, connection:%p, reason: %s\n", xio_session_event_str(event_data->event), session, event_data->conn, xio_strerror(event_data->reason)); switch (event_data->event) { case XIO_SESSION_NEW_CONNECTION_EVENT: if (tdata) tdata->connection = event_data->conn; break; case XIO_SESSION_CONNECTION_TEARDOWN_EVENT: xio_connection_destroy(event_data->conn); if (tdata) tdata->connection = NULL; break; case XIO_SESSION_TEARDOWN_EVENT: xio_session_destroy(session); for (i = 0; i < sdata->tdata_nr; i++) { process_request(&sdata->tdata[i], NULL); xio_context_stop_loop(sdata->tdata[i].ctx); } xio_context_stop_loop((struct xio_context *)sdata->ctx); break; default: break; }; return 0; }
/*---------------------------------------------------------------------------*/ static int on_session_event(struct xio_session *session, struct xio_session_event_data *event_data, void *cb_user_context) { struct xio_connection_params cparams; struct test_params *test_params = cb_user_context; printf("session event: %s. session:%p, connection:%p, reason: %s\n", xio_session_event_str(event_data->event), session, event_data->conn, xio_strerror(event_data->reason)); switch (event_data->event) { case XIO_SESSION_NEW_CONNECTION_EVENT: /* assign connection private data */ cparams.user_context = cb_user_context; xio_set_connection_params(event_data->conn, &cparams); break; case XIO_SESSION_REJECT_EVENT: xio_disconnect(event_data->conn); break; case XIO_SESSION_CONNECTION_TEARDOWN_EVENT: printf("last sent:%"PRIu64", last comp:%"PRIu64", " \ "delta:%"PRIu64"\n", test_params->nsent, test_params->ncomp, test_params->nsent-test_params->ncomp); xio_connection_destroy(event_data->conn); break; case XIO_SESSION_TEARDOWN_EVENT: xio_session_destroy(session); xio_context_stop_loop(test_params->ctx, 0); break; default: break; }; return 0; }
static int on_session_event(struct xio_session *session, struct xio_session_event_data *event_data, void *cb_user_context) { struct client_data *client_data = (struct client_data *)cb_user_context; switch (event_data->event) { case XIO_SESSION_CONNECTION_TEARDOWN_EVENT: xio_connection_destroy(event_data->conn); xio_context_stop_loop(client_data->ctx); /* exit */ break; case XIO_SESSION_TEARDOWN_EVENT: xio_session_destroy(session); xio_context_stop_loop(client_data->ctx); /* exit */ break; default: sd_debug("other event: %d", event_data->event); break; }; return 0; }
/*---------------------------------------------------------------------------*/ static int on_session_event(struct xio_session *session, struct xio_session_event_data *event_data, void *cb_user_context) { struct session_data *session_data = cb_user_context; printf("session event: %s. reason: %s\n", xio_session_event_str(event_data->event), xio_strerror(event_data->reason)); switch (event_data->event) { case XIO_SESSION_CONNECTION_TEARDOWN_EVENT: xio_connection_destroy(event_data->conn); break; case XIO_SESSION_TEARDOWN_EVENT: xio_session_destroy(session); event_base_loopbreak(session_data->evbase); break; default: break; }; return 0; }
/*---------------------------------------------------------------------------*/ static int on_session_event(struct xio_session *session, struct xio_session_event_data *event_data, void *cb_user_context) { struct ow_test_params *ow_params = (struct ow_test_params *)cb_user_context; printf("session event: %s. reason: %s\n", xio_session_event_str(event_data->event), xio_strerror(event_data->reason)); switch (event_data->event) { case XIO_SESSION_CONNECTION_TEARDOWN_EVENT: xio_connection_destroy(event_data->conn); break; case XIO_SESSION_TEARDOWN_EVENT: xio_context_stop_loop(ow_params->ctx); /* exit */ break; default: break; }; return 0; }