1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-02-27 13:57:23 +03:00

F #4809: Do not doble-unlock raft mutex in timer. Fix update of

heartbeat counter
This commit is contained in:
Ruben S. Montero 2017-05-24 23:57:37 +02:00
parent 98d26e9e4c
commit c8d88de091
4 changed files with 19 additions and 13 deletions

View File

@ -179,7 +179,7 @@ protected:
bool leader_only; //Method can be only execute by leaders or solo servers
long long xmlrpc_timeout;
static const long long xmlrpc_timeout; //Timeout (ms) for request forwarding
/* ---------------------------------------------------------------------- */
/* Class Constructors */
@ -195,9 +195,6 @@ protected:
log_method_call = true;
leader_only = true;
//TODO Get this from oned.conf (10s)
xmlrpc_timeout = 10000;
};
virtual ~Request(){};

View File

@ -31,7 +31,7 @@ public:
RequestManagerProxy(string _method): Request("RequestManagerProxy", "?",
"Forwards the request to another OpenNebula"), method(_method)
{
method_name = ("RequestManagerProxy." + method);
method_name = method;
};
~RequestManagerProxy(){};

View File

@ -719,14 +719,21 @@ void RaftManager::timer_action(const ActionRequest& ar)
if ((sec < the_time.tv_sec) || (sec == the_time.tv_sec &&
nsec <= the_time.tv_nsec))
{
clock_gettime(CLOCK_REALTIME, &last_heartbeat);
pthread_mutex_unlock(&mutex);
send_heartbeat();
}
pthread_mutex_unlock(&mutex);
pthread_mutex_lock(&mutex);
clock_gettime(CLOCK_REALTIME, &last_heartbeat);
pthread_mutex_unlock(&mutex);
}
else
{
pthread_mutex_unlock(&mutex);
}
}
else if ( state == FOLLOWER )
{
@ -741,14 +748,14 @@ void RaftManager::timer_action(const ActionRequest& ar)
state = CANDIDATE;
clock_gettime(CLOCK_REALTIME, &last_heartbeat);
pthread_mutex_unlock(&mutex);
request_vote();
}
pthread_mutex_unlock(&mutex);
else
{
pthread_mutex_unlock(&mutex);
}
}
else
{

View File

@ -260,6 +260,8 @@ void Request::log_xmlrpc_value(const xmlrpc_c::value& v, std::ostringstream& oss
string Request::format_str;
const long long Request::xmlrpc_timeout = 10000;
/* -------------------------------------------------------------------------- */
void Request::execute(