Changeset 8e7a1b


Ignore:
Timestamp:
Mar 9, 2017, 10:16:58 PM (8 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_StructOpt_integration_tests, AutomationFragmentation_failures, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph_documentation, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_ChronosMutex, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, GeometryObjects, Gui_displays_atomic_force_velocity, IndependentFragmentGrids_IntegrationTest, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, PartialCharges_OrthogonalSummation, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, RotateToPrincipalAxisSystem_UndoRedo, StoppableMakroAction, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, Ubuntu_1604_changes, stable
Children:
f67dfb
Parents:
c300e2
git-author:
Frederik Heber <heber@…> (02/23/17 14:26:57)
git-committer:
Frederik Heber <heber@…> (03/09/17 22:16:58)
Message:

AsyncOperation now sets a status code to indicate resolver failure.

Location:
ThirdParty/JobMarket/src/JobMarket/Operations
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified ThirdParty/JobMarket/src/JobMarket/Operations/AsyncOperation.cpp

    rc300e2 r8e7a1b  
    3333#include "CodePatterns/Log.hpp"
    3434
    35 void NoOp() {}
     35static void NoOp() {}
    3636
    3737// static instances
     
    4848  {
    4949    LOG(1, "INFO: AsyncOperation completed.");
     50    status = Operation::success;
    5051    callback_on_success();
    5152  }
     
    5455    // An error occurred.
    5556    ELOG(1, e.message());
     57    status = Operation::error;
    5658    callback_on_failure();
    5759  }
     
    7678  DEBUG_FUNCTION_ENTRYEXIT
    7779
     80  status = Operation::running;
     81
    7882  // Resolve the host name into an IP address.
    7983  boost::asio::ip::tcp::resolver resolver(connection_.socket().get_io_service());
    8084  boost::asio::ip::tcp::resolver::query query(_host, _service);
     85  boost::system::error_code ec;
    8186  boost::asio::ip::tcp::resolver::iterator endpoint_iterator =
    82     resolver.resolve(query);
    83   boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator;
     87    resolver.resolve(query, ec);
     88  // check whether host could be resolved
     89  if (endpoint_iterator != boost::asio::ip::tcp::resolver::iterator()) {
     90    boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator;
    8491
    85   // Start an asynchronous connect operation.
    86   LOG(3, "DEBUG: Connecting asynchronously to endpoint " << endpoint << " ...");
    87   connection_.socket().async_connect(endpoint,
    88     boost::bind(&AsyncOperation::handle_connect, this,
    89       boost::asio::placeholders::error, ++endpoint_iterator));
     92    // Start an asynchronous connect operation.
     93    LOG(3, "DEBUG: Connecting asynchronously to endpoint " << endpoint << " ...");
     94    connection_.socket().async_connect(endpoint,
     95      boost::bind(&AsyncOperation::handle_connect, this,
     96        boost::asio::placeholders::error, ++endpoint_iterator));
     97  } else {
     98    // this will allow to still listen on the socket for other connections
     99    handle_FinishOperation(ec);
     100  }
    90101}
  • TabularUnified ThirdParty/JobMarket/src/JobMarket/Operations/Operation.hpp

    rc300e2 r8e7a1b  
    3434  Operation(const std::string &_name, Connection &_connection) :
    3535    connection_(_connection),
     36    status(not_started),
    3637    name(_name)
    3738  {}
     
    5657  }
    5758
     59  //!> enumeration of status codes of the operation
     60  enum StatusCodes {
     61    not_started,
     62    running,
     63    error,
     64    success
     65  };
     66
     67  /** Returns the current status of the operation.
     68   *
     69   * \return status code
     70   */
     71  enum StatusCodes getStatus() const {
     72    return status;
     73  }
     74
    5875protected:
    59   /// The Connection to the server.
     76  //!> The Connection to the server.
    6077  Connection &connection_;
    6178
     79  //!> current status of the operation
     80  enum StatusCodes status;
     81
    6282private:
    63   /// Name of this AsyncOperation (required for Registry pattern)
     83  //!> Name of this AsyncOperation (required for Registry pattern)
    6484  std::string name;
    6585};
  • TabularUnified ThirdParty/JobMarket/src/JobMarket/Operations/SyncOperation.cpp

    rc300e2 r8e7a1b  
    4242  boost::asio::ip::tcp::resolver::iterator endpoint_iterator =
    4343    resolver.resolve(query);
    44   boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator;
     44  // check whether host could be resolved
     45  if (endpoint_iterator != boost::asio::ip::tcp::resolver::iterator()) {
     46    boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator;
    4547
    46   // Start an asynchronous connect operation.
    47   LOG(3, "DEBUG: Connecting synchronously to endpoint " << endpoint << " ...");
    48   connection_.socket().connect(endpoint);
     48    // Start an asynchronous connect operation.
     49    LOG(3, "DEBUG: Connecting synchronously to endpoint " << endpoint << " ...");
     50    connection_.socket().connect(endpoint);
     51  } else {
     52    status = Operation::error;
     53  }
    4954}
    5055
     
    6772  DEBUG_FUNCTION_ENTRYEXIT
    6873
     74  status = Operation::running;
     75
    6976  // connect
    7077  connect(_host, _service);
     
    7582  // disconnect
    7683  disconnect();
     84
     85  if (status == Operation::running)
     86    status = Operation::success;
    7787}
Note: See TracChangeset for help on using the changeset viewer.