case XIO_SESSION_CONNECTION_CLOSED_EVENT: /* orderly discon */
case XIO_SESSION_CONNECTION_DISCONNECTED_EVENT: /* unexpected discon */
case XIO_SESSION_CONNECTION_REFUSED_EVENT:
- ldout(cct,2) << xio_session_event_types[event_data->event]
- << " user_context " << event_data->conn_user_context << dendl;
xcon = static_cast<XioConnection*>(event_data->conn_user_context);
+ ldout(cct,2) << xio_session_event_types[event_data->event]
+ << " xcon " << xcon << " session " << session << dendl;
if (likely(!!xcon)) {
Spinlock::Locker lckr(conns_sp);
XioConnection::EntitySet::iterator conn_iter =
}
break;
case XIO_SESSION_CONNECTION_TEARDOWN_EVENT:
- ldout(cct,2) << xio_session_event_types[event_data->event]
- << " user_context " << event_data->conn_user_context << dendl;
xcon = static_cast<XioConnection*>(event_data->conn_user_context);
+ ldout(cct,2) << xio_session_event_types[event_data->event]
+ << " xcon " << xcon << " session " << session << dendl;
xcon->on_teardown_event();
break;
case XIO_SESSION_TEARDOWN_EVENT:
* we can always set it explicitly */
struct xio_connection_params xcp = {};
xcp.session = xcon->session;
- xcp.ctx = this->portals.get_portal0()->ctx;
+ xcp.ctx = xcon->portal->ctx;
xcp.conn_user_context = xcon;
xcon->conn = xio_connect(&xcp);
char **p_vec;
int n;
int last_unused;
- int max_conns_per_ctx;
public:
XioPortals(Messenger *msgr, int _n, int nconns) : p_vec(NULL), last_unused(0)
{
- max_conns_per_ctx = nconns;
n = max(_n, 1);
- /* portal0 */
- portals.push_back(new XioPortal(msgr, nconns));
- /* additional portals allocated on bind() */
+
+ portals.resize(n);
+ for (int i = 0; i < n; i++) {
+ if (!portals[i]) {
+ portals[i] = new XioPortal(msgr, nconns);
+ assert(portals[i] != nullptr);
+ }
+ }
}
vector<XioPortal*>& get() { return portals; }
return pix;
}
- XioPortal* get_portal0()
+ XioPortal* get_next_portal()
{
- return portals[0];
+ int pix = get_last_unused();
+ return portals[pix];
}
int bind(struct xio_session_ops *ops, const string& base_uri,
p_vec = new char*[nportals];
for (p_ix = 0; p_ix < nportals; ++p_ix) {
portal = portals[p_ix];
- /* shift left */
p_vec[p_ix] = (char*) /* portal->xio_uri.c_str() */
portal->portal_id;
}