macchina-io / macchina.io

macchina.io EDGE is a powerful C++ and JavaScript SDK for edge devices, multi-service IoT gateways and connected embedded systems.
https://macchina.io
GNU General Public License v3.0
512 stars 152 forks source link

Poco::Util::Timer Cancel(true) hangs forever #103

Open JyotstnaDeviChintala opened 3 years ago

JyotstnaDeviChintala commented 3 years ago

Expected Behavior

When a Poco::Util::Timer is Cancelled using Cancel(true) while a Cancel(false) is already in execution state, it hangs forever.

Actual Behavior

Clear all the pending notifications and exit gracefully without hanging.

Steps to Reproduce

  1. Create a Poco::Util::Timer timer.
  2. Trigger timer.cancel().
  3. Immediately call timer.cancel(true);

Poco::Util::Timer timer1; timer1.cancel(). timer1.cancel(true);

(please make this a SSCCE, if applicable and reasonable)

macchina.io Version

macchina.io-2018.11.06-7c725bf8

Compiler and Version

gcc

Operating System and Version

Windows 10, Android x86_64 and amd64

Other Relevant Information

Proposed solution:

The second pending cancel notification (cancel(true) , which has an _finished event waiting is never set. This needs to be set, before clearing the queue.

namespace Poco { namespace Util {

class TimerNotification: public Poco::Notification { public: virtual void set(); }

class CancelNotification: public TimerNotification { public: bool execute() { ... else if (pNf.cast<CancelNotification>()) { pNf->set(); } } void set() { _finished.set(); } }

} }