Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gmsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Larry Price
gmsh
Commits
e966b70e
Commit
e966b70e
authored
12 years ago
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
revert loop on subclients for now until we find a better way to clean up the servers
parent
2938666b
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Fltk/gmshLocalNetworkClient.h
+3
-0
3 additions, 0 deletions
Fltk/gmshLocalNetworkClient.h
Fltk/onelabGroup.cpp
+40
-47
40 additions, 47 deletions
Fltk/onelabGroup.cpp
with
43 additions
and
47 deletions
Fltk/gmshLocalNetworkClient.h
+
3
−
0
View file @
e966b70e
...
@@ -12,6 +12,9 @@
...
@@ -12,6 +12,9 @@
class
gmshLocalNetworkClient
:
public
onelab
::
localNetworkClient
{
class
gmshLocalNetworkClient
:
public
onelab
::
localNetworkClient
{
private:
private:
// a gmsh local network client can launch subclients (this is typical for a
// metamodel that calls several underlying models); _clients keeps track of
// the master (this) and the subclients.
std
::
vector
<
gmshLocalNetworkClient
*>
_clients
;
std
::
vector
<
gmshLocalNetworkClient
*>
_clients
;
public:
public:
gmshLocalNetworkClient
(
const
std
::
string
&
name
,
const
std
::
string
&
executable
,
gmshLocalNetworkClient
(
const
std
::
string
&
name
,
const
std
::
string
&
executable
,
...
...
This diff is collapsed.
Click to expand it.
Fltk/onelabGroup.cpp
+
40
−
47
View file @
e966b70e
...
@@ -61,7 +61,6 @@ class onelabGmshServer : public GmshServer{
...
@@ -61,7 +61,6 @@ class onelabGmshServer : public GmshServer{
~
onelabGmshServer
(){}
~
onelabGmshServer
(){}
int
NonBlockingSystemCall
(
const
char
*
str
)
int
NonBlockingSystemCall
(
const
char
*
str
)
{
{
//std::cout << "System call: " << str << std::endl;
return
SystemCall
(
str
);
return
SystemCall
(
str
);
}
}
int
NonBlockingWait
(
double
waitint
,
double
timeout
,
int
socket
)
int
NonBlockingWait
(
double
waitint
,
double
timeout
,
int
socket
)
...
@@ -169,7 +168,6 @@ std::string getNextToken(const std::string &msg,
...
@@ -169,7 +168,6 @@ std::string getNextToken(const std::string &msg,
bool
gmshLocalNetworkClient
::
receiveMessage
()
bool
gmshLocalNetworkClient
::
receiveMessage
()
{
{
bool
showMessages
=
false
;
double
timer
=
GetTimeInSeconds
();
double
timer
=
GetTimeInSeconds
();
if
(
!
getGmshServer
()){
if
(
!
getGmshServer
()){
...
@@ -182,16 +180,12 @@ bool gmshLocalNetworkClient::receiveMessage()
...
@@ -182,16 +180,12 @@ bool gmshLocalNetworkClient::receiveMessage()
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
(
showMessages
)
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
])){
Msg
::
Error
(
"Abnormal server termination (did not receive message body)"
);
Msg
::
Error
(
"Abnormal server termination (did not receive message body)"
);
return
false
;
return
false
;
}
}
// else if(showMessages)
// std::cout << "Received message: " << message << " from " << getName() << std::endl;
switch
(
type
)
{
switch
(
type
)
{
case
GmshSocket
::
GMSH_START
:
case
GmshSocket
::
GMSH_START
:
...
@@ -352,8 +346,7 @@ bool gmshLocalNetworkClient::receiveMessage()
...
@@ -352,8 +346,7 @@ bool gmshLocalNetworkClient::receiveMessage()
std
::
string
::
size_type
first
=
0
;
std
::
string
::
size_type
first
=
0
;
std
::
string
clientName
=
getNextToken
(
message
,
first
);
std
::
string
clientName
=
getNextToken
(
message
,
first
);
std
::
string
command
=
getNextToken
(
message
,
first
);
std
::
string
command
=
getNextToken
(
message
,
first
);
gmshLocalNetworkClient
*
subClient
=
gmshLocalNetworkClient
*
subClient
=
new
gmshLocalNetworkClient
(
clientName
,
command
);
new
gmshLocalNetworkClient
(
clientName
,
command
);
onelabGmshServer
*
server
=
new
onelabGmshServer
(
subClient
);
onelabGmshServer
*
server
=
new
onelabGmshServer
(
subClient
);
subClient
->
setPid
(
0
);
subClient
->
setPid
(
0
);
...
@@ -368,8 +361,6 @@ bool gmshLocalNetworkClient::receiveMessage()
...
@@ -368,8 +361,6 @@ bool gmshLocalNetworkClient::receiveMessage()
subClient
->
setGmshServer
(
server
);
subClient
->
setGmshServer
(
server
);
addClient
(
subClient
);
addClient
(
subClient
);
std
::
cout
<<
"Gmsh has "
<<
getNumClients
()
<<
" clients
\n
"
;
std
::
cout
<<
"Gmsh has "
<<
getNumClients
()
<<
" clients
\n
"
;
// std::string reply = "Connected !!";
// getGmshServer()->SendMessage(GmshSocket::GMSH_CONNECT, reply.size(), &reply[0]);
}
}
}
}
break
;
break
;
...
@@ -415,66 +406,68 @@ bool gmshLocalNetworkClient::run()
...
@@ -415,66 +406,68 @@ bool gmshLocalNetworkClient::run()
Msg
::
StatusBar
(
true
,
"Running '%s'..."
,
_name
.
c_str
());
Msg
::
StatusBar
(
true
,
"Running '%s'..."
,
_name
.
c_str
());
setGmshServer
(
server
);
setGmshServer
(
server
);
int
i
=
0
;
while
(
1
)
{
while
(
1
)
{
// loop on all the clients (usually only one, but can be more if we spawned
// loop on all the clients (usually only one, but can be more if we spawned
// subclients; in that case we might want to start from the one after the
// subclients; in that case we might want to start from the one after the
// one we read from last, for better load balancing)
// 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
;
if
(
getExecutable
().
empty
()
&&
!
CTX
::
instance
()
->
solver
.
listen
){
if
(
getExecutable
().
empty
()
&&
!
CTX
::
instance
()
->
solver
.
listen
){
// we stopped listening to the special "Listen" client
// we stopped listening to the special "Listen" client
stop
=
true
;
stop
=
true
;
break
;
break
;
}
}
c
=
getClient
(
i
);
for
(
int
i
=
0
;
i
<
getNumClients
();
i
++
){
//std::cout << "client " << i << "/" << getNumClients() << " pid= " << c->getPid();
if
(
getExecutable
().
empty
()
&&
!
CTX
::
instance
()
->
solver
.
listen
){
// we stopped listening to the special "Listen" client
if
(
c
->
getPid
()
<
0
){
stop
=
true
;
if
(
c
==
this
){
// the "master" client stopped
break
;
stop
=
true
;
}
else
{
// this subclient is not active anymore
std
::
string
reply
=
c
->
getName
();
getGmshServer
()
->
SendMessage
(
GmshSocket
::
GMSH_OPTION_1
,
reply
.
size
(),
&
reply
[
0
]);
onelab
::
server
::
instance
()
->
unregisterClient
(
c
);
removeClient
(
c
);
Msg
::
StatusBar
(
true
,
"Done running '%s'"
,
c
->
getName
().
c_str
());
i
=
0
;
// start over with the only client that surely exists
continue
;
}
}
}
c
=
getClient
(
i
);
GmshServer
*
s
=
c
->
getGmshServer
();
if
(
c
->
getPid
()
<
0
){
if
(
!
s
){
if
(
c
==
this
){
// the "master" client stopped
Msg
::
Error
(
"Abnormal server termination (no valid server)"
);
stop
=
true
;
stop
=
true
;
break
;
}
}
else
{
else
{
// this subclient is not active anymore
int
ret
=
s
->
NonBlockingWait
(
0.001
,
-
1.
);
continue
;
//std::cout << " ret = " << ret << std::endl;
}
if
(
ret
==
0
){
haveData
=
true
;
// we have data from this particular client
}
}
else
if
(
ret
==
3
){
GmshServer
*
s
=
c
->
getGmshServer
();
//pass on to the next client
if
(
!
s
){
Msg
::
Error
(
"Abnormal server termination (no valid server)"
);
stop
=
true
;
break
;
}
}
else
{
// an error occurred
else
{
stop
=
true
;
int
ret
=
s
->
NonBlockingWait
(
0.001
,
-
1.
);
if
(
ret
==
0
){
// we have data from this particular client
haveData
=
true
;
break
;
}
else
if
(
ret
==
3
){
// pass to the next client
continue
;
}
else
{
// an error occurred
stop
=
true
;
break
;
}
}
}
}
}
if
(
stop
)
break
;
if
(
stop
)
break
;
if
(
haveData
&&
!
c
->
receiveMessage
())
break
;
if
(
haveData
&&
!
c
->
receiveMessage
())
break
;
if
(
c
==
this
&&
c
->
getPid
()
<
0
)
break
;
if
(
c
==
this
&&
c
->
getPid
()
<
0
)
break
;
i
++
;
if
(
i
>=
getNumClients
())
i
=
0
;
}
}
// we are done running the (master) client: delete the servers and the
// we are done running the (master) client: delete the servers and the
// subclients, if any. We do not delete the servers when we disconnect to make
// subclients, if any. The servers are not deleted upon GMSH_STOP in
// sure we always delete them, even when we disconnect "uncleanly"
// receiveMessage() to make sure we always delete them, even when the
// disconnect was not clean.
for
(
int
i
=
0
;
i
<
getNumClients
();
i
++
){
for
(
int
i
=
0
;
i
<
getNumClients
();
i
++
){
gmshLocalNetworkClient
*
c
=
getClient
(
i
);
gmshLocalNetworkClient
*
c
=
getClient
(
i
);
GmshServer
*
s
=
c
->
getGmshServer
();
GmshServer
*
s
=
c
->
getGmshServer
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment