1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-22 13:33:52 +03:00

B : Prevent race conditions on sync notifications

This commit is contained in:
Ruben S. Montero 2017-09-14 12:43:24 +02:00
parent 477b2a63f2
commit e3f2452c95

View File

@ -33,7 +33,8 @@ public:
message(""),
timeout(false),
id(-1),
time_out(0)
time_out(0),
notified(false)
{
am.addListener(this);
};
@ -65,6 +66,8 @@ public:
*/
void notify()
{
notified = true;
am.finalize();
};
@ -73,6 +76,11 @@ public:
*/
void wait()
{
if ( notified )
{
return;
}
time_out = time(0) + 90;//Requests will expire in 1.5 minutes
am.loop();
@ -83,6 +91,11 @@ public:
*/
void wait(time_t t)
{
if ( notified )
{
return;
}
am.loop(t);
};
@ -95,6 +108,11 @@ protected:
*/
time_t time_out;
/**
* True if the request has been notified
*/
bool notified;
/**
* The ActionManager that will be notify when the request is ready.
*/