Skip to content
Snippets Groups Projects
Commit 8239aa84 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

better doc

parent 3155a7ce
No related branches found
No related tags found
No related merge requests found
...@@ -159,8 +159,6 @@ bool gmshLocalNetworkClient::receiveMessage(int &type) ...@@ -159,8 +159,6 @@ bool gmshLocalNetworkClient::receiveMessage(int &type)
Msg::Error("Abnormal server termination (did not receive message header)"); Msg::Error("Abnormal server termination (did not receive message header)");
return false; return false;
} }
else if(false)
std::cout << "Received header: " << type << " from " << getName() << std::endl;
std::string message(length, ' '); std::string message(length, ' ');
if(!getGmshServer()->ReceiveMessage(length, &message[0])){ if(!getGmshServer()->ReceiveMessage(length, &message[0])){
...@@ -394,17 +392,12 @@ bool gmshLocalNetworkClient::run() ...@@ -394,17 +392,12 @@ bool gmshLocalNetworkClient::run()
break; break;
} }
// loop on all the clients (usually only one, but can be more if we spawned // loop over all the clients (usually only one, but can be more if we
// subclients; in that case we might want to start from the one after the // spawned subclients) and check if data is available for one of them
// one we read from last, for better load balancing)
bool stop = false, haveData = false; bool stop = false, haveData = false;
gmshLocalNetworkClient *c = 0; gmshLocalNetworkClient *c = 0;
for(int i = 0; i < getNumClients(); i++){ for(int i = 0; i < getNumClients(); i++){
c = getClient(i); c = getClient(i);
//std::cout << " client " << i << "/" << getNumClients()
// << " pid= " << c->getPid() << std::endl;
if(c->getPid() < 0){ if(c->getPid() < 0){
if(c == this){ // the "master" client stopped if(c == this){ // the "master" client stopped
stop = true; stop = true;
...@@ -435,14 +428,23 @@ bool gmshLocalNetworkClient::run() ...@@ -435,14 +428,23 @@ bool gmshLocalNetworkClient::run()
} }
} }
} }
int type=0;
// break the while(1) if the master client has stopped or if we encountered
// a problem
if(stop) break; if(stop) break;
// if data is available try to get the message from the corresponding
// client; break the while(1) if we could not receive the message
int type = 0;
if(haveData && !c->receiveMessage(type)) break; if(haveData && !c->receiveMessage(type)) break;
// if the client is a subclient and it stopped, notify the master
if((c != this) && (type == GmshSocket::GMSH_STOP)){ if((c != this) && (type == GmshSocket::GMSH_STOP)){
std::string reply = c->getName(); std::string reply = c->getName();
getGmshServer()->SendMessage(GmshSocket::GMSH_STOP, reply.size(), &reply[0]); getGmshServer()->SendMessage(GmshSocket::GMSH_STOP, reply.size(), &reply[0]);
//onelab::server::instance()->unregisterClient(c);
} }
// break the while(1) if the master client has stopped
if(c == this && c->getPid() < 0) break; if(c == this && c->getPid() < 0) break;
} }
...@@ -459,6 +461,8 @@ bool gmshLocalNetworkClient::run() ...@@ -459,6 +461,8 @@ bool gmshLocalNetworkClient::run()
delete s; delete s;
} }
if(c != this){ if(c != this){
if(c->getPid() > 0)
Msg::Error("Subclient %s was not stopped correctly", c->getName().c_str());
removeClient(c); removeClient(c);
delete c; delete c;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment