From 675eccddc9dae905012f20c396fc149149abaf9c Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Fri, 29 Apr 2016 14:13:21 +0000
Subject: [PATCH] kill clients when finalizing onelab

---
 Common/GmshMessage.cpp |  6 ++++++
 Common/onelab.h        | 34 ++++++++++++++++++++++++----------
 2 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/Common/GmshMessage.cpp b/Common/GmshMessage.cpp
index 1621cc1eb8..d0db92abc8 100644
--- a/Common/GmshMessage.cpp
+++ b/Common/GmshMessage.cpp
@@ -1271,6 +1271,12 @@ void Msg::SetOnelabChanged(int value, const std::string &client)
 void Msg::FinalizeOnelab()
 {
 #if defined(HAVE_ONELAB)
+  // kill any running clients
+  for(onelab::server::citer it = onelab::server::instance()->firstClient();
+      it != onelab::server::instance()->lastClient(); it++){
+    (*it)->kill();
+  }
+  // delete local client
   if(_onelabClient){
     delete _onelabClient;
     _onelabClient = 0;
diff --git a/Common/onelab.h b/Common/onelab.h
index 5d946c8544..e0950bef64 100644
--- a/Common/onelab.h
+++ b/Common/onelab.h
@@ -720,14 +720,24 @@ namespace onelab{
         if(!done) done = _clear(name, client, _strings);
       }
     }
-    bool set(const number &p,
-             const std::string &client=""){ return _set(p, client, _numbers); }
-    bool set(const string &p,
-             const std::string &client=""){ return _set(p, client, _strings); }
+    bool set(const number &p, const std::string &client="")
+    {
+      return _set(p, client, _numbers);
+    }
+    bool set(const string &p, const std::string &client="")
+    {
+      return _set(p, client, _strings);
+    }
     bool get(std::vector<number> &ps, const std::string &name="",
-             const std::string &client=""){ return _get(ps, name, client, _numbers); }
+             const std::string &client="")
+    {
+      return _get(ps, name, client, _numbers);
+    }
     bool get(std::vector<onelab::string> &ps, const std::string &name="",
-             const std::string &client=""){ return _get(ps, name, client, _strings); }
+             const std::string &client="")
+    {
+      return _get(ps, name, client, _strings);
+    }
     void getPtr(number **ptr, const std::string name, const std::string client="")
     {
       *ptr = _getPtr(name, client, _numbers);
@@ -1228,10 +1238,14 @@ namespace onelab{
     }
     virtual bool set(const number &p){ return _set(p); }
     virtual bool set(const string &p){ return _set(p); }
-    virtual bool get(std::vector<number> &ps,
-                     const std::string &name=""){ return _get(ps, name); }
-    virtual bool get(std::vector<onelab::string> &ps,
-                     const std::string &name=""){ return _get(ps, name); }
+    virtual bool get(std::vector<number> &ps, const std::string &name="")
+    {
+      return _get(ps, name);
+    }
+    virtual bool get(std::vector<onelab::string> &ps, const std::string &name="")
+    {
+      return _get(ps, name);
+    }
     void sendInfo(const std::string &msg)
     {
       if(_gmshClient) _gmshClient->Info(msg.c_str());
-- 
GitLab