1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-11 05:17:41 +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(""), message(""),
timeout(false), timeout(false),
id(-1), id(-1),
time_out(0) time_out(0),
notified(false)
{ {
am.addListener(this); am.addListener(this);
}; };
@ -65,6 +66,8 @@ public:
*/ */
void notify() void notify()
{ {
notified = true;
am.finalize(); am.finalize();
}; };
@ -73,6 +76,11 @@ public:
*/ */
void wait() void wait()
{ {
if ( notified )
{
return;
}
time_out = time(0) + 90;//Requests will expire in 1.5 minutes time_out = time(0) + 90;//Requests will expire in 1.5 minutes
am.loop(); am.loop();
@ -83,6 +91,11 @@ public:
*/ */
void wait(time_t t) void wait(time_t t)
{ {
if ( notified )
{
return;
}
am.loop(t); am.loop(t);
}; };
@ -95,6 +108,11 @@ protected:
*/ */
time_t time_out; time_t time_out;
/**
* True if the request has been notified
*/
bool notified;
/** /**
* The ActionManager that will be notify when the request is ready. * The ActionManager that will be notify when the request is ready.
*/ */