From: Vu Pham Date: Fri, 30 Jan 2015 17:21:37 +0000 (-0800) Subject: xio: Enforce at least two portals if bind X-Git-Tag: v0.93~99^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b1435e6e77e9691e763d842fdba6d59de6fb0eb7;p=ceph.git xio: Enforce at least two portals if bind Enforce at least two portals being set/created if one set xio_portals_thread = 1 by mistake Return the correct last use portal and pass in only one portal to accept Signed-off-by: Vu Pham --- diff --git a/src/msg/xio/XioPortal.h b/src/msg/xio/XioPortal.h index 8d248d23d753..cd7a2e702580 100644 --- a/src/msg/xio/XioPortal.h +++ b/src/msg/xio/XioPortal.h @@ -343,12 +343,17 @@ private: int last_use; public: - XioPortals(Messenger *msgr, int _n) : p_vec(NULL), n(_n) + XioPortals(Messenger *msgr, int _n) : p_vec(NULL) { /* portal0 */ portals.push_back(new XioPortal(msgr)); last_use = 0; + /* enforce at least two portals if bind */ + if (_n < 2) + _n = 2; + n = _n; + /* additional portals allocated on bind() */ } @@ -367,7 +372,7 @@ public: int get_last_use() { int pix = last_use; - if (++last_use == get_portals_len() - 2) + if (++last_use >= get_portals_len() - 1) last_use = 0; return pix; } @@ -389,7 +394,7 @@ public: return xio_accept(session, (const char **)&(portals_vec[pix]), - 2, NULL, 0); + 1, NULL, 0); } void start()