Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions ACE/ace/Timer_List_T.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,15 @@ ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::schedule_i (const TYPE &

if (n != 0)
{
long id = this->id_counter_++;

long id = this->id_counter_;
if (this->id_counter_ < LONG_MAX)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::numeric_limits::max(), prefix increment, and could id ever be -1?

Copy link
Copy Markdown
Contributor Author

@okan-nako okan-nako May 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, current type of "id_counter_" is "long" (Timer_List_T.h:# 211 --> long id_counter_;), we encountered even the overflow (-1).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But with the new proposed code, I don't see how it can become -1, or do I miss something?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in case "long id = this->id_counter_++;", "id" becomes "-1" when overflow happens.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was in the old code, now you check < LONGMAX

{
this->id_counter_++;
}
else
{
this->id_counter_ = 0;
}
if (id != -1) {
n->set (type, act, future_time, interval, 0, 0, id);
this->schedule_i (n, future_time);
Expand Down
Loading