This is an automated email from the ASF dual-hosted git repository.
zwoop pushed a commit to branch 8.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/8.0.x by this push:
new fb0019b make sure the index stays positive
fb0019b is described below
commit fb0019bfed4e43a880872cfc3f7c63add9b04eed
Author: Fei Deng <[email protected]>
AuthorDate: Mon Jul 9 09:58:44 2018 -0500
make sure the index stays positive
(cherry picked from commit 2d3e9d7366ae9225286d304607975a9651656119)
---
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 5beac84..ba58de9 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;
}