فهرست منبع

fix idx out of range (#391)

xiaojin 2 سال پیش
والد
کامیت
c0f8fba5ee
1فایلهای تغییر یافته به همراه1 افزوده شده و 1 حذف شده
  1. 1 1
      evpp/EventLoopThreadPool.h

+ 1 - 1
evpp/EventLoopThreadPool.h

@@ -34,7 +34,7 @@ public:
         int idx = 0;
         if (lb == LB_RoundRobin) {
             if (++next_loop_idx_ >= numLoops) next_loop_idx_ = 0;
-            idx = next_loop_idx_;
+            idx = next_loop_idx_.fetch_and(numLoops);
         } else if (lb == LB_Random) {
             idx = hv_rand(0, numLoops - 1);
         } else if (lb == LB_LeastConnections) {