Skip to content

Commit

Permalink
Fixed bug with negative offsets
Browse files Browse the repository at this point in the history
  • Loading branch information
haug-den-lucas authored and levy committed Jul 15, 2024
1 parent 3af5f7e commit 8068407
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/inet/queueing/gate/PeriodicGate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ void PeriodicGate::initializeGating()
{
index = 0;
isOpen_ = initiallyOpen;
offset.setRaw(totalDuration != 0 ? initialOffset.raw() % totalDuration.raw() : 0);
if (totalDuration.raw() == 0) {
offset.setRaw(0);
} else {
offset.setRaw((initialOffset.raw() % totalDuration.raw() + totalDuration.raw()) % totalDuration.raw());
}
while (offset > CLOCKTIME_ZERO) {
clocktime_t duration = durations[index];
if (offset >= duration) {
Expand Down

0 comments on commit 8068407

Please sign in to comment.