Skip to content

Poco::Timer problem #230

@yuntinghill

Description

@yuntinghill

In time synchronization if adjust time back, the Timer will waitfor a long time more longer than the periodicInterval.

void Timer::run()
{
    Poco::Timestamp now;
    long interval(0);
    do
    {
        long sleep(0);
        do
        {
            now.update();
            sleep = static_cast<long>((_nextInvocation - now)/1000);
            if (sleep < 0)
            {
                if (interval == 0)
                {
                    sleep = 0;
                    break;
                }
                _nextInvocation += static_cast<Timestamp::TimeVal>(interval)*1000;
                ++_skipped;
            }
        }
        while (sleep < 0);

        if (_wakeUp.tryWait(sleep))  //if system time be adjusted back tryWait function will trap in a long wait 

         //Should this line be change to 
        if (_wakeUp.tryWait(sleep>getPeriodicInterval()?getPeriodicInterval():sleep))

                 .......

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions