Index: src/Fragmentation/Automation/ExitflagContainer.hpp
===================================================================
--- src/Fragmentation/Automation/ExitflagContainer.hpp	(revision d57585e6a2a4bac3922a30b0d4538287bd9d1987)
+++ src/Fragmentation/Automation/ExitflagContainer.hpp	(revision d57585e6a2a4bac3922a30b0d4538287bd9d1987)
@@ -0,0 +1,62 @@
+/*
+ * ExitflagContainer.hpp
+ *
+ *  Created on: 11.05.2012
+ *      Author: heber
+ */
+
+#ifndef EXITFLAGCONTAINER_HPP_
+#define EXITFLAGCONTAINER_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+/** This class simply contains an exit flag to be inherited by instances that
+ * deal with (asynchronous) operations. These may be given a callback function
+ * that sets the exitflag to ErrorFlag in case of failure, e.g
+ *
+ * \code
+ * const boost::function<void ()> failed =
+ *    boost::bind(&ExitflagContainer::setExitflag, boost::ref(this), ErrorFlag);
+ * \endcode
+ * where \a this refers to the inheriting instance.
+ *
+ */
+class ExitflagContainer
+{
+public:
+  ExitflagContainer() :
+    Exitflag(OkFlag)
+  {}
+
+  enum Exitflag_t {
+    OkFlag = 0,
+    ErrorFlag = 255
+  };
+
+  /** Getter for Exitflag.
+   *
+   * @return Exitflag
+   */
+  size_t getExitflag() const
+  {
+    return Exitflag;
+  }
+
+  /** Setter for Exitflag.
+   *
+   * @param exitflag
+   */
+  void setExitflag(const Exitflag_t _Exitflag)
+  {
+    Exitflag = _Exitflag;
+  }
+
+private:
+  // exit flag of this operation, derived classes may change it
+  enum Exitflag_t Exitflag;
+};
+
+#endif /* EXITFLAGCONTAINER_HPP_ */
Index: src/Fragmentation/Automation/FragmentController.cpp
===================================================================
--- src/Fragmentation/Automation/FragmentController.cpp	(revision 9db22d3dcf243224ac36894c1c0683c009857077)
+++ src/Fragmentation/Automation/FragmentController.cpp	(revision d57585e6a2a4bac3922a30b0d4538287bd9d1987)
@@ -47,14 +47,15 @@
 FragmentController::FragmentController(
     boost::asio::io_service& io_service) :
-    connection_(io_service)
+    connection_(io_service),
+    failed(boost::bind(&ExitflagContainer::setExitflag, this, ExitflagContainer::ErrorFlag))
 {
   Info info(__FUNCTION__);
 
   // insert commands into registry
-  Commands.registerInstance(new CheckResultsOperation(connection_, AsyncOperation::NoOpCallback));
-  Commands.registerInstance(new GetNextJobIdOperation(connection_, AsyncOperation::NoOpCallback));
-  Commands.registerInstance(new ReceiveResultsOperation(connection_, AsyncOperation::NoOpCallback));
+  Commands.registerInstance(new CheckResultsOperation(connection_, AsyncOperation::NoOpCallback, failed));
+  Commands.registerInstance(new GetNextJobIdOperation(connection_, AsyncOperation::NoOpCallback, failed));
+  Commands.registerInstance(new ReceiveResultsOperation(connection_, AsyncOperation::NoOpCallback, failed));
   Commands.registerInstance(new RemoveAllWorkerOperation(connection_));
-  Commands.registerInstance(new SendJobsOperation(connection_, AsyncOperation::NoOpCallback));
+  Commands.registerInstance(new SendJobsOperation(connection_, AsyncOperation::NoOpCallback, failed));
   Commands.registerInstance(new ShutdownOperation(connection_));
 }
@@ -67,20 +68,4 @@
   Commands.cleanup();
 }
-
-/** Getter for Exitflag of all any Operation.
- *
- * We simply go through all of them and check which failed.
- *
- * @return Combined Exitflag of all Operations in \a Commands.
- */
-size_t FragmentController::getExitflag() const
-{
-  for (OperationRegistry::const_iterator iter = Commands.getBeginIter();
-      iter != Commands.getEndIter(); ++iter)
-    if ((iter->second)->getExitflag() != 0)
-      return (iter->second)->getExitflag();
-  return 0;
-}
-
 
 /** Requests an available id from server
Index: src/Fragmentation/Automation/FragmentController.hpp
===================================================================
--- src/Fragmentation/Automation/FragmentController.hpp	(revision 9db22d3dcf243224ac36894c1c0683c009857077)
+++ src/Fragmentation/Automation/FragmentController.hpp	(revision d57585e6a2a4bac3922a30b0d4538287bd9d1987)
@@ -19,4 +19,5 @@
 
 #include "Connection.hpp"
+#include "ExitflagContainer.hpp"
 #include "JobId.hpp"
 #include "Jobs/FragmentJob.hpp"
@@ -34,12 +35,9 @@
  * of the fragments on distant computers.
  */
-class FragmentController
+class FragmentController : public ExitflagContainer
 {
 public:
   FragmentController(boost::asio::io_service& io_service);
   ~FragmentController();
-
-  /// getter for operations exit flag.
-  size_t getExitflag() const;
 
   void requestIds(const std::string &host, const std::string &service, const size_t NumberIds);
@@ -61,4 +59,8 @@
   //!> registry with all operations of this controller
   OperationRegistry Commands;
+
+private:
+  //!> internally bound function that sets the Exitflag to ErrorFlag
+  boost::function<void ()> failed;
 };
 
Index: src/Fragmentation/Automation/Makefile.am
===================================================================
--- src/Fragmentation/Automation/Makefile.am	(revision 9db22d3dcf243224ac36894c1c0683c009857077)
+++ src/Fragmentation/Automation/Makefile.am	(revision d57585e6a2a4bac3922a30b0d4538287bd9d1987)
@@ -93,4 +93,5 @@
 FRAGMENTATIONAUTOMATIONHELPERHEADER = \
   atexit.hpp \
+  ExitflagContainer.hpp \
   GlobalJobId.hpp \
   Listener.hpp \
Index: src/Fragmentation/Automation/Operations/AsyncOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Operations/AsyncOperation.cpp	(revision 9db22d3dcf243224ac36894c1c0683c009857077)
+++ src/Fragmentation/Automation/Operations/AsyncOperation.cpp	(revision d57585e6a2a4bac3922a30b0d4538287bd9d1987)
@@ -53,5 +53,4 @@
   {
     // An error occurred.
-    Exitflag = ErrorFlag;
     ELOG(1, e.message());
     callback_on_failure();
Index: src/Fragmentation/Automation/Operations/Controllers/CheckResultsOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Operations/Controllers/CheckResultsOperation.cpp	(revision 9db22d3dcf243224ac36894c1c0683c009857077)
+++ src/Fragmentation/Automation/Operations/Controllers/CheckResultsOperation.cpp	(revision d57585e6a2a4bac3922a30b0d4538287bd9d1987)
@@ -60,6 +60,6 @@
     // operation the io_service will run out of work to do and the client will
     // exit.
-    Exitflag = ErrorFlag;
     ELOG(1, e.message());
+    AsyncOperation::handle_FinishOperation(e);
   }
 }
@@ -84,6 +84,6 @@
   {
     // An error occurred.
-    Exitflag = ErrorFlag;
     ELOG(1, e.message());
+    AsyncOperation::handle_FinishOperation(e);
   }
 }
Index: src/Fragmentation/Automation/Operations/Controllers/GetNextJobIdOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Operations/Controllers/GetNextJobIdOperation.cpp	(revision 9db22d3dcf243224ac36894c1c0683c009857077)
+++ src/Fragmentation/Automation/Operations/Controllers/GetNextJobIdOperation.cpp	(revision d57585e6a2a4bac3922a30b0d4538287bd9d1987)
@@ -62,4 +62,5 @@
     // exit.
     ELOG(1, e.message());
+    AsyncOperation::handle_FinishOperation(e);
   }
 }
@@ -85,4 +86,5 @@
     // An error occurred.
     ELOG(1, e.message());
+    AsyncOperation::handle_FinishOperation(e);
   }
 }
@@ -108,4 +110,5 @@
     // An error occurred.
     ELOG(1, e.message());
+    AsyncOperation::handle_FinishOperation(e);
   }
 }
Index: src/Fragmentation/Automation/Operations/Controllers/ReceiveResultsOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Operations/Controllers/ReceiveResultsOperation.cpp	(revision 9db22d3dcf243224ac36894c1c0683c009857077)
+++ src/Fragmentation/Automation/Operations/Controllers/ReceiveResultsOperation.cpp	(revision d57585e6a2a4bac3922a30b0d4538287bd9d1987)
@@ -62,6 +62,6 @@
     // operation the io_service will run out of work to do and the client will
     // exit.
-    Exitflag = ErrorFlag;
     ELOG(1, e.message());
+    AsyncOperation::handle_FinishOperation(e);
   }
 }
@@ -86,6 +86,6 @@
   {
     // An error occurred.
-    Exitflag = ErrorFlag;
     ELOG(1, e.message());
+    AsyncOperation::handle_FinishOperation(e);
   }
 }
Index: src/Fragmentation/Automation/Operations/Controllers/SendJobsOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Operations/Controllers/SendJobsOperation.cpp	(revision 9db22d3dcf243224ac36894c1c0683c009857077)
+++ src/Fragmentation/Automation/Operations/Controllers/SendJobsOperation.cpp	(revision d57585e6a2a4bac3922a30b0d4538287bd9d1987)
@@ -63,6 +63,6 @@
     // operation the io_service will run out of work to do and the client will
     // exit.
-    Exitflag = ErrorFlag;
     ELOG(1, e.message());
+    AsyncOperation::handle_FinishOperation(e);
   }
 }
@@ -88,6 +88,6 @@
   {
     // An error occurred.
-    Exitflag = ErrorFlag;
     ELOG(1, e.message());
+    AsyncOperation::handle_FinishOperation(e);
   }
 
Index: src/Fragmentation/Automation/Operations/Operation.hpp
===================================================================
--- src/Fragmentation/Automation/Operations/Operation.hpp	(revision 9db22d3dcf243224ac36894c1c0683c009857077)
+++ src/Fragmentation/Automation/Operations/Operation.hpp	(revision d57585e6a2a4bac3922a30b0d4538287bd9d1987)
@@ -34,5 +34,4 @@
   Operation(const std::string &_name, Connection &_connection) :
     connection_(_connection),
-    Exitflag(OkFlag),
     name(_name)
   {}
@@ -49,19 +48,5 @@
   virtual void operator()(const std::string& _host, const std::string& _service) = 0;
 
-  enum Exitflag_t {
-    OkFlag = 0,
-    ErrorFlag = 255
-  };
-
-  /** Getter for Exitflag.
-   *
-   * @return Exitflag
-   */
-  size_t getExitflag() const
-  {
-    return Exitflag;
-  }
-
-  /** Getter for name.
+ /** Getter for name.
    *
    * @return const reference to Operation::name.
@@ -75,7 +60,4 @@
   Connection &connection_;
 
-  // exit flag of this operation, derived classes may change it
-  enum Exitflag_t Exitflag;
-
 private:
   /// Name of this AsyncOperation (required for Registry pattern)
Index: src/Fragmentation/Automation/Operations/Servers/SendJobToWorkerOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Operations/Servers/SendJobToWorkerOperation.cpp	(revision 9db22d3dcf243224ac36894c1c0683c009857077)
+++ src/Fragmentation/Automation/Operations/Servers/SendJobToWorkerOperation.cpp	(revision d57585e6a2a4bac3922a30b0d4538287bd9d1987)
@@ -59,6 +59,6 @@
     // operation the io_service will run out of work to do and the client will
     // exit.
-    Exitflag = ErrorFlag;
     ELOG(1, e.message());
+    AsyncOperation::handle_FinishOperation(e);
   }
 }
Index: src/Fragmentation/Automation/Operations/Servers/ShutdownWorkerOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Operations/Servers/ShutdownWorkerOperation.cpp	(revision 9db22d3dcf243224ac36894c1c0683c009857077)
+++ src/Fragmentation/Automation/Operations/Servers/ShutdownWorkerOperation.cpp	(revision d57585e6a2a4bac3922a30b0d4538287bd9d1987)
@@ -62,6 +62,6 @@
     // operation the io_service will run out of work to do and the client will
     // exit.
-    Exitflag = ErrorFlag;
     ELOG(1, e.message());
+    AsyncOperation::handle_FinishOperation(e);
   }
 }
Index: src/Fragmentation/Automation/Operations/Workers/EnrollInPoolOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Operations/Workers/EnrollInPoolOperation.cpp	(revision 9db22d3dcf243224ac36894c1c0683c009857077)
+++ src/Fragmentation/Automation/Operations/Workers/EnrollInPoolOperation.cpp	(revision d57585e6a2a4bac3922a30b0d4538287bd9d1987)
@@ -57,4 +57,5 @@
     // exit.
     ELOG(1, e.message());
+    AsyncOperation::handle_FinishOperation(e);
   }
 }
@@ -80,4 +81,5 @@
     // exit.
     ELOG(1, e.message());
+    AsyncOperation::handle_FinishOperation(e);
   }
 }
@@ -101,4 +103,5 @@
     // exit.
     ELOG(1, e.message());
+    AsyncOperation::handle_FinishOperation(e);
   }
 }
Index: src/Fragmentation/Automation/Operations/Workers/ObtainJobOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Operations/Workers/ObtainJobOperation.cpp	(revision 9db22d3dcf243224ac36894c1c0683c009857077)
+++ src/Fragmentation/Automation/Operations/Workers/ObtainJobOperation.cpp	(revision d57585e6a2a4bac3922a30b0d4538287bd9d1987)
@@ -57,4 +57,5 @@
     // exit.
     ELOG(1, e.message());
+    AsyncOperation::handle_FinishOperation(e);
   }
 }
Index: src/Fragmentation/Automation/Operations/Workers/SubmitResultOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Operations/Workers/SubmitResultOperation.cpp	(revision 9db22d3dcf243224ac36894c1c0683c009857077)
+++ src/Fragmentation/Automation/Operations/Workers/SubmitResultOperation.cpp	(revision d57585e6a2a4bac3922a30b0d4538287bd9d1987)
@@ -57,6 +57,6 @@
     // operation the io_service will run out of work to do and the client will
     // exit.
-    exitflag = ErrorFlag;
     ELOG(1, e.message());
+    AsyncOperation::handle_FinishOperation(e);
   }
 }
@@ -79,6 +79,6 @@
     // operation the io_service will run out of work to do and the client will
     // exit.
-    exitflag = ErrorFlag;
     ELOG(1, e.message());
+    AsyncOperation::handle_FinishOperation(e);
   }
 }
@@ -101,6 +101,6 @@
     // operation the io_service will run out of work to do and the client will
     // exit.
-    exitflag = ErrorFlag;
     ELOG(1, e.message());
+    AsyncOperation::handle_FinishOperation(e);
   }
 }
Index: src/Fragmentation/Automation/Operations/Workers/SubmitResultOperation.hpp
===================================================================
--- src/Fragmentation/Automation/Operations/Workers/SubmitResultOperation.hpp	(revision 9db22d3dcf243224ac36894c1c0683c009857077)
+++ src/Fragmentation/Automation/Operations/Workers/SubmitResultOperation.hpp	(revision d57585e6a2a4bac3922a30b0d4538287bd9d1987)
@@ -34,6 +34,5 @@
     AsyncOperation(std::string("submitresult"),_connection, _callback_on_success, _callback_on_failure),
     result( new FragmentResult(JobId::NoJob, std::string("EmptyResult")) ),
-    address(_address),
-    exitflag(OkFlag)
+    address(_address)
   {}
   /// Destructor for class SubmitResultOperation
@@ -48,18 +47,4 @@
     result.reset();
     result = _result;
-  }
-
-public:
-  enum {
-    OkFlag = 0,
-    ErrorFlag = 1
-  };
-
-  /** Returns the flag of the handled operation.
-   *
-   */
-  size_t getFlag() const
-  {
-    return exitflag;
   }
 
@@ -84,7 +69,4 @@
   //!> address for listener
   WorkerAddress address;
-
-  /// exit flag
-  size_t exitflag;
 };
 
Index: src/Fragmentation/Automation/Pool/PoolWorker.cpp
===================================================================
--- src/Fragmentation/Automation/Pool/PoolWorker.cpp	(revision 9db22d3dcf243224ac36894c1c0683c009857077)
+++ src/Fragmentation/Automation/Pool/PoolWorker.cpp	(revision d57585e6a2a4bac3922a30b0d4538287bd9d1987)
@@ -68,6 +68,7 @@
   address(listenhost, listenservice),
   connection_(_io_service),
-  enrollOp(connection_, address, AsyncOperation::NoOpCallback, AsyncOperation::NoOpCallback),
-  submitOp(connection_, address, AsyncOperation::NoOpCallback, AsyncOperation::NoOpCallback),
+  failed(boost::bind(&ExitflagContainer::setExitflag, this, ExitflagContainer::ErrorFlag)),
+  enrollOp(connection_, address, AsyncOperation::NoOpCallback, failed),
+  submitOp(connection_, address, AsyncOperation::NoOpCallback, failed),
   submitresult(boost::bind(&AsyncOperation::operator(),
       boost::ref(submitOp),
Index: src/Fragmentation/Automation/Pool/PoolWorker.hpp
===================================================================
--- src/Fragmentation/Automation/Pool/PoolWorker.hpp	(revision 9db22d3dcf243224ac36894c1c0683c009857077)
+++ src/Fragmentation/Automation/Pool/PoolWorker.hpp	(revision d57585e6a2a4bac3922a30b0d4538287bd9d1987)
@@ -21,4 +21,5 @@
 #include <vector>
 #include "Connection.hpp"
+#include "ExitflagContainer.hpp"
 #include "Jobs/FragmentJob.hpp"
 #include "Operations/Workers/EnrollInPoolOperation.hpp"
@@ -31,5 +32,5 @@
  *
  */
-class PoolWorker
+class PoolWorker : public ExitflagContainer
 {
 public:
@@ -47,5 +48,9 @@
   size_t getFlag() const
   {
-    return submitOp.getFlag() + PoolListener.getExitflag();
+    if (PoolListener.getExitflag())
+      return PoolListener.getExitflag();
+    if (getExitflag())
+      return getExitflag();
+    return 0;
   }
 
@@ -95,4 +100,7 @@
   Connection connection_;
 
+  //!> internally bound function that sets the Exitflag to ErrorFlag
+  boost::function<void ()> failed;
+
   //!> operation that handles obtaining a job
   EnrollInPoolOperation enrollOp;
