File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -101,15 +101,24 @@ CommandResponse RoundRobin::CommandSetGates(
101101void RoundRobin::ProcessBatch (bess::PacketBatch *batch) {
102102 gate_idx_t out_gates[bess::PacketBatch::kMaxBurst ];
103103
104+ if (ngates_ <= 0 ) {
105+ bess::Packet::Free (batch);
106+ return ;
107+ }
108+
104109 if (per_packet_) {
105110 for (int i = 0 ; i < batch->cnt (); i++) {
106111 out_gates[i] = gates_[current_gate_];
107- current_gate_ = (current_gate_ + 1 ) % ngates_;
112+ if (++current_gate_ >= ngates_) {
113+ current_gate_ = 0 ;
114+ }
108115 }
109116 RunSplit (out_gates, batch);
110117 } else {
111118 gate_idx_t gate = gates_[current_gate_];
112- current_gate_ = (current_gate_ + 1 ) % ngates_;
119+ if (++current_gate_ >= ngates_) {
120+ current_gate_ = 0 ;
121+ }
113122 RunChooseModule (gate, batch);
114123 }
115124}
You can’t perform that action at this time.
0 commit comments