Variable server restart issues

Added mutexes in the variable server listener thread and each variable server thread.
During checkpoint restart all of these mutexes are locked by the master thread to
stop accepting new connections and stop all read/writing to all variable server clients.
Communication is resumed after the checkpoint has been reloaded.

refs #168
This commit is contained in:
Alex Lin
2016-04-19 13:50:30 -05:00
parent fad36fc544
commit 8c3e322ed1
7 changed files with 47 additions and 5 deletions

View File

@ -3,6 +3,10 @@
#include "trick/VariableServerThread.hh"
void Trick::VariableServerThread::preload_checkpoint() {
// Stop variable server processing at the top of the processing loop.
pthread_mutex_lock(&restart_pause);
// Let the thread complete any data copying it has to do
// and then suspend data copying until the checkpoint is reloaded.
pthread_mutex_lock(&copy_mutex);
@ -23,15 +27,19 @@ void Trick::VariableServerThread::preload_checkpoint() {
(*it)->ref->attr->units = (char *)"--" ;
(*it)->ref->attr->size = sizeof(int) ;
}
}
void Trick::VariableServerThread::restart() {
// Set the pause state of this thread back to its "pre-checkpoint reload" state.
pause_cmd = saved_pause_cmd ;
// Allow data copying to continue.
pthread_mutex_unlock(&copy_mutex);
}
void Trick::VariableServerThread::restart() {
// Set the pause state of this thread back to its "pre-checkpoint reload" state.
pause_cmd = saved_pause_cmd ;
// Restart the variable server processing.
pthread_mutex_unlock(&restart_pause);
}