This is an automated email from the ASF dual-hosted git repository.

duke8253 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 2d3e9d7  make sure the index stays positive
2d3e9d7 is described below

commit 2d3e9d7366ae9225286d304607975a9651656119
Author: Fei Deng <[email protected]>
AuthorDate: Mon Jul 9 09:58:44 2018 -0500

    make sure the index stays positive
---
 iocore/eventsystem/P_UnixEventProcessor.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/iocore/eventsystem/P_UnixEventProcessor.h 
b/iocore/eventsystem/P_UnixEventProcessor.h
index b03a5b2..859eb92 100644
--- a/iocore/eventsystem/P_UnixEventProcessor.h
+++ b/iocore/eventsystem/P_UnixEventProcessor.h
@@ -54,7 +54,12 @@ EventProcessor::assign_thread(EventType etype)
 
   ink_assert(etype < MAX_EVENT_TYPES);
   if (tg->_count > 1) {
-    next = tg->_next_round_robin++ % tg->_count;
+    // When "_next_round_robin" grows big enough, it becomes a negative number,
+    // meaning "next" is also negative. And since "next" is used as an index
+    // into array "_thread", the result is returning NULL when assigning 
threads.
+    // So we need to cast "_next_round_robin" to unsigned int so the result 
stays
+    // positive.
+    next = static_cast<unsigned int>(++tg->_next_round_robin) % tg->_count;
   } else {
     next = 0;
   }

Reply via email to