diff --git a/Common/GmshSocket.h b/Common/GmshSocket.h index de602076e09f0c50a0a31ad2c1cf39d3e74bf246..a0b779b9e92f74a2163b98b78d34d57b660b9c84 100644 --- a/Common/GmshSocket.h +++ b/Common/GmshSocket.h @@ -156,10 +156,10 @@ class GmshSocket{ WSACleanup(); #endif } - // utility function to wait for some data to read on a socket (if - // seconds and microseconds == 0 we check for available data and - // return immediately, i.e., we do polling). Returns 0 when data is - // available. + // Wait for some data to read on the socket (if seconds and microseconds == 0 + // we check for available data and return immediately, i.e., we do + // polling). Returns 1 when data is available, 0 when nothing happened before + // the time delay, -1 on error. int Select(int seconds, int microseconds, int socket=-1) { int s = (socket < 0) ? _sock : socket; @@ -169,8 +169,8 @@ class GmshSocket{ fd_set rfds; FD_ZERO(&rfds); FD_SET(s, &rfds); - // select checks all IO descriptors between 0 and its first arg, - // minus 1... hence the +1 below + // select checks all IO descriptors between 0 and its first arg, minus 1; + // hence the +1 below int ret = select(s + 1, &rfds, NULL, NULL, &tv); if(ret > 0 && FD_ISSET(s, &rfds)) return 1; return ret; @@ -327,7 +327,7 @@ class GmshServer : public GmshSocket{ GmshServer() : GmshSocket(), _portno(-1) {} virtual ~GmshServer(){} virtual int NonBlockingSystemCall(const char *str) = 0; - virtual int NonBlockingWait(int socket, double waitint, double timeout) = 0; + virtual int NonBlockingWait(double waitint, double timeout, int socket=-1) = 0; // start the client by launching "command" (command is supposed to contain // '%s' where the socket name should appear) int Start(const char *command, const char *sockname, double timeout) @@ -412,7 +412,7 @@ class GmshServer : public GmshSocket{ } // wait until we get data - int ret = NonBlockingWait(tmpsock, 0.001, timeout); + int ret = NonBlockingWait(0.001, timeout, tmpsock); if(ret){ CloseSocket(tmpsock); if(ret == 2){ diff --git a/Fltk/onelabGroup.cpp b/Fltk/onelabGroup.cpp index cca1fa7305fabfad6cfd40fb3c38f2e3c622b8aa..c023d21363e76d2cece18daa66dae5527c9551f7 100644 --- a/Fltk/onelabGroup.cpp +++ b/Fltk/onelabGroup.cpp @@ -58,8 +58,11 @@ class onelabGmshServer : public GmshServer{ onelabGmshServer(onelab::localNetworkClient *client) : GmshServer(), _client(client) {} ~onelabGmshServer(){} - int NonBlockingSystemCall(const char *str){ return SystemCall(str); } - int NonBlockingWait(int socket, double waitint, double timeout) + int NonBlockingSystemCall(const char *str) + { + return SystemCall(str); + } + int NonBlockingWait(double waitint, double timeout, int socket) { double start = GetTimeInSeconds(); while(1){ @@ -413,7 +416,7 @@ bool gmshLocalNetworkClient::run() stop = true; break; } - else if(!s->NonBlockingWait(-1, 0.001, 0.)){ + else if(!s->NonBlockingWait(0.001, 0.)){ // we have data from this particular client haveData = true; break; diff --git a/contrib/onelab/OnelabClients.cpp b/contrib/onelab/OnelabClients.cpp index 0bd7f9b6550bf522e6dee958421cf4e245dd4cf1..c56b7f887f1ece8cfb32e74e5df939525df07029 100644 --- a/contrib/onelab/OnelabClients.cpp +++ b/contrib/onelab/OnelabClients.cpp @@ -19,7 +19,7 @@ class onelabMetaModelServer : public GmshServer{ ~onelabMetaModelServer(){} int NonBlockingSystemCall(const char *str){ return SystemCall(str); } - int NonBlockingWait(int socket, double waitint, double timeout) + int NonBlockingWait(double waitint, double timeout, int socket) { double start = GetTimeInSeconds(); while(1){ @@ -374,7 +374,7 @@ void localSolverClient::FixExecPath(const std::string &in) if (outfile.is_open()){ outfile << "#!/bin/bash" << std::endl; outfile << "export ELMER_HOME=\"" << elmerHome << "\"" << std::endl; - outfile << "export DYLD_LIBRARY_PATH=\".:$ELMER_HOME/lib:$DYLD_LIBRARY_PATH\"" << std::endl; + outfile << "export DYLD_LIBRARY_PATH=\".:$ELMER_HOME/lib:$DYLD_LIBRARY_PATH\"" << std::endl; outfile << in << std::endl; } else @@ -618,7 +618,7 @@ bool remoteClient::syncInputFile(const std::string &wdir, const std::string &fil } else { //should be found remote if(!checkIfPresentRemote(split[1])){ - OLMsg::Error("The remote input file <%s> is not present", + OLMsg::Error("The remote input file <%s> is not present", split[1].c_str()); return false; } @@ -639,7 +639,7 @@ bool remoteClient::syncOutputFile(const std::string &wdir, const std::string &fi if(checkIfPresentRemote(split[1])){ if(split[0].size()){ // the file must be copied back on local host - cmd.assign("rsync -e ssh -auv " + _remoteHost + ":"); + cmd.assign("rsync -e ssh -auv " + _remoteHost + ":"); if(_remoteDir.size()) cmd.append(_remoteDir); cmd.append(split[1]); @@ -671,7 +671,7 @@ void MetaModel::analyze() { OLMsg::Info("===== ANALYZING"); std::string fileName = getWorkingDir() + genericNameFromArgs + onelabExtension; openOnelabBlock(); - OLMsg::Info("Parse file <%s> %s", fileName.c_str(), + OLMsg::Info("Parse file <%s> %s", fileName.c_str(), parse_onefile(fileName)?"done":"failed"); closeOnelabBlock(); } @@ -680,7 +680,7 @@ void MetaModel::compute() { OLMsg::Info("===== COMPUTING"); std::string fileName = getWorkingDir() + genericNameFromArgs + onelabExtension; openOnelabBlock(); - OLMsg::Info("Parse file <%s> %s", fileName.c_str(), + OLMsg::Info("Parse file <%s> %s", fileName.c_str(), parse_onefile(fileName)?"done":"failed"); closeOnelabBlock(); onelab::server::instance()->setChanged(false); @@ -689,10 +689,10 @@ void MetaModel::compute() { void MetaModel::registerClient(const std::string &name, const std::string &type, const std::string &cmdl, const std::string &host, const std::string &rdir) { localSolverClient *c; - // Clients are assigned by default the same (local) working dir + // Clients are assigned by default the same (local) working dir // as the MetaModel, i.e. the working dir from args // A working (local relative) subdir (useful to organize submodels) - // can be defined with the command: client.workingSubdir(subdir) + // can be defined with the command: client.workingSubdir(subdir) if(host.empty() || !host.compare("localhost")){ //local client if(!type.compare(0,6,"interf")) c= new InterfacedClient(name,cmdl,getWorkingDir()); @@ -747,7 +747,7 @@ void InterfacedClient::analyze() { std::string fileName = getWorkingDir() + split[1] + split[2]; if(!checkIfPresent(fileName)) OLMsg::Error("The file <%s> is not present",fileName.c_str()); - OLMsg::Info("Parse file <%s> %s", fileName.c_str(), + OLMsg::Info("Parse file <%s> %s", fileName.c_str(), parse_onefile(fileName)?"done":"failed"); } } @@ -880,7 +880,7 @@ void EncapsulatedClient::analyze() { std::string fileName = getWorkingDir() + split[1] + split[2]; if(!checkIfPresent(fileName)) OLMsg::Error("The file <%s> is not present",fileName.c_str()); - OLMsg::Info("Parse file <%s> %s", fileName.c_str(), + OLMsg::Info("Parse file <%s> %s", fileName.c_str(), parse_onefile(fileName)?"done":"failed"); } } @@ -1114,7 +1114,7 @@ void RemoteNativeClient::compute(){ for(unsigned int i = 0; i < choices.size(); i++) if(syncOutputFile(getWorkingDir(), choices[i])) OLMsg::Info("ok"); - } + } } @@ -1346,7 +1346,7 @@ std::vector<std::string> SplitOLHostName(const std::string &in) std::vector<std::string> s(2); size_t pos = in.find(":"); if(pos == std::string::npos){ - s[0] = in; + s[0] = in; s[1] = ""; } else{