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

simplify logic

parent 585b29bd
Branches
Tags
No related merge requests found
...@@ -156,10 +156,20 @@ void GmshRemote::run(std::string args) ...@@ -156,10 +156,20 @@ void GmshRemote::run(std::string args)
break; break;
int type, length; int type, length;
if(server->ReceiveHeader(&type, &length)){ if(!server->ReceiveHeader(&type, &length)){
Msg::Error("Did not receive message header: stopping server");
break;
}
double timer = GetTimeInSeconds(); double timer = GetTimeInSeconds();
char *message = new char[length + 1]; char *message = new char[length + 1];
if(server->ReceiveString(length, message)){ if(!server->ReceiveString(length, message)){
Msg::Error("Did not receive message body: stopping server");
delete [] message;
break;
}
switch (type) { switch (type) {
case GmshSocket::GMSH_START: case GmshSocket::GMSH_START:
_pid = atoi(message); _pid = atoi(message);
...@@ -209,8 +219,8 @@ void GmshRemote::run(std::string args) ...@@ -209,8 +219,8 @@ void GmshRemote::run(std::string args)
Msg::Direct(1, "%-8.8s: %s", name.c_str(), message); Msg::Direct(1, "%-8.8s: %s", name.c_str(), message);
break; break;
case GmshSocket::GMSH_SPEED_TEST: case GmshSocket::GMSH_SPEED_TEST:
Msg::Info("got %d Mb message in %g seconds", strlen(message) Msg::Info("got %d Mb message in %g seconds",
/ 1024 / 1024, GetTimeInSeconds() - timer); length / 1024 / 1024, GetTimeInSeconds() - timer);
break; break;
case GmshSocket::GMSH_VERTEX_ARRAY: case GmshSocket::GMSH_VERTEX_ARRAY:
{ {
...@@ -222,22 +232,12 @@ void GmshRemote::run(std::string args) ...@@ -222,22 +232,12 @@ void GmshRemote::run(std::string args)
} }
break; break;
default: default:
Msg::Warning("Unknown message type"); Msg::Warning("Received unknown message type (%d)", type);
Msg::Direct("%-8.8s: %s", name.c_str(), message);
break;
}
FlGui::instance()->check();
}
else{
Msg::Warning("Failed to receive message body on socket: aborting");
break; break;
} }
delete [] message; delete [] message;
} FlGui::instance()->check();
else{
// didn't get any header, just abort
break;
}
} }
if(window){ if(window){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment