Ignore:
Timestamp:
Apr 10, 2018, 6:42:56 AM (7 years ago)
Author:
Frederik Heber <frederik.heber@…>
Branches:
AutomationFragmentation_failures, Candidate_v1.6.1, ChemicalSpaceEvaluator, Enhanced_StructuralOptimization_continued, Exclude_Hydrogens_annealWithBondGraph, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_contraction-expansion, Gui_displays_atomic_force_velocity, JobMarket_RobustOnKillsSegFaults, PythonUI_with_named_parameters, StoppableMakroAction, TremoloParser_IncreasedPrecision
Children:
cdfb6f
Parents:
1e58bb
git-author:
Frederik Heber <frederik.heber@…> (04/07/18 21:52:17)
git-committer:
Frederik Heber <frederik.heber@…> (04/10/18 06:42:56)
Message:

FIX: SyncOperation now checks error codes from connect and close.

  • FragmentController checks the derived SyncOperations' status in order to set the exit flag. Now, if we cannot connect to the server, then the controller will have a non-zero exit flag.
  • Note that the exitflag was set already for all AsyncOperations.
Location:
ThirdParty/JobMarket/src/JobMarket
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • ThirdParty/JobMarket/src/JobMarket/Controller/FragmentController.cpp

    r1e58bb ra5c293  
    173173    const std::string &service)
    174174{
    175   GetNumberWorkersOperation *checkres = static_cast<GetNumberWorkersOperation *>(
     175  GetNumberWorkersOperation *numberworkers = static_cast<GetNumberWorkersOperation *>(
    176176      Commands.getByName("numberworkers"));
    177   (*checkres)(host, service);
     177  (*numberworkers)(host, service);
    178178}
    179179
     
    197197std::vector<size_t> FragmentController::getNumberOfWorkers()
    198198{
    199   const GetNumberWorkersOperation * const checkres = static_cast<const GetNumberWorkersOperation *>(
     199  const GetNumberWorkersOperation * const numberworkers = static_cast<const GetNumberWorkersOperation *>(
    200200      Commands.getByName("numberworkers"));
    201   return checkres->get();
     201  return numberworkers->get();
    202202}
    203203
     
    214214      Commands.getByName("removeallresults"));
    215215  (*removeall)(host, service);
     216  setExitflagFromStatus(*removeall);
    216217}
    217218
     
    228229      Commands.getByName("removealljobs"));
    229230  (*removeall)(host, service);
     231  setExitflagFromStatus(*removeall);
    230232}
    231233
     
    242244      Commands.getByName("removeallworker"));
    243245  (*removeall)(host, service);
     246  setExitflagFromStatus(*removeall);
    244247}
    245248
     
    304307  job->setId(_newid);
    305308}
     309
     310/** helper function to set exit flag from SyncOperations' status.
     311 *
     312 * \param op operation whose status to check
     313 */
     314void FragmentController::setExitflagFromStatus(const Operation &op)
     315{
     316  if (op.getStatus() == Operation::success)
     317    setExitflag(ExitflagContainer::OkFlag);
     318  else
     319    setExitflag(ExitflagContainer::ErrorFlag);
     320}
  • ThirdParty/JobMarket/src/JobMarket/Controller/FragmentController.hpp

    r1e58bb ra5c293  
    7373  boost::function<void ()> failed;
    7474
     75  void setExitflagFromStatus(const Operation &op);
     76
    7577private:
    7678  //!> grant this specifically made proxy access to jobids
  • ThirdParty/JobMarket/src/JobMarket/Operations/SyncOperation.cpp

    r1e58bb ra5c293  
    4848    // Start an asynchronous connect operation.
    4949    LOG(3, "DEBUG: Connecting synchronously to endpoint " << endpoint << " ...");
    50     connection_.socket().connect(endpoint);
     50    boost::system::error_code ec;
     51    connection_.socket().connect(endpoint, ec);
     52    if (ec) {
     53      ELOG(1, ec.message());
     54      status = Operation::error;
     55    }
    5156  } else {
    5257    status = Operation::error;
     
    6065void SyncOperation::disconnect()
    6166{
    62   connection_.socket().close();
     67  boost::system::error_code ec;
     68  connection_.socket().close(ec);
     69  if (ec) {
     70    ELOG(1, ec.message());
     71    status = Operation::error;
     72  }
    6373}
    6474
     
    7888
    7989  // call virtual function to continue
    80   internal();
     90  if (status == Operation::running)
     91    internal();
    8192
    8293  // disconnect
    83   disconnect();
     94  if (status == Operation::running)
     95    disconnect();
    8496
    8597  if (status == Operation::running)
Note: See TracChangeset for help on using the changeset viewer.