Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of framagit.org:simgrid/simgrid
[simgrid.git] / src / kernel / activity / IoImpl.cpp
index 8601126..1a7e46f 100644 (file)
@@ -5,17 +5,11 @@
 
 #include <simgrid/Exception.hpp>
 #include <simgrid/kernel/routing/NetPoint.hpp>
-#include <simgrid/s4u/Engine.hpp>
-#include <simgrid/s4u/Host.hpp>
 
-#include "mc/mc.h"
 #include "src/kernel/activity/IoImpl.hpp"
 #include "src/kernel/actor/ActorImpl.hpp"
-#include "src/kernel/actor/SimcallObserver.hpp"
-#include "src/kernel/resource/CpuImpl.hpp"
 #include "src/kernel/resource/DiskImpl.hpp"
 #include "src/kernel/resource/HostImpl.hpp"
-#include "src/mc/mc_replay.hpp"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_io, kernel, "Kernel io-related synchronization");
 
@@ -44,14 +38,6 @@ IoImpl& IoImpl::update_sharing_penalty(double sharing_penalty)
   return *this;
 }
 
-IoImpl& IoImpl::set_timeout(double timeout)
-{
-  const s4u::Host* host = get_disk()->get_host();
-  timeout_detector_     = host->get_cpu()->sleep(timeout);
-  timeout_detector_->set_activity(this);
-  return *this;
-}
-
 IoImpl& IoImpl::set_type(s4u::Io::OpType type)
 {
   type_ = type;
@@ -109,36 +95,6 @@ IoImpl* IoImpl::start()
   return this;
 }
 
-void IoImpl::post()
-{
-  performed_ioops_ = model_action_->get_cost();
-  if (model_action_->get_state() == resource::Action::State::FAILED) {
-    if (host_ && dst_host_) { // this is an I/O stream
-      if (not host_->is_on())
-       set_state(State::SRC_HOST_FAILURE);
-      else if (not dst_host_->is_on())
-       set_state(State::DST_HOST_FAILURE);
-    } else if ((disk_ && not disk_->is_on()) || (dst_disk_ && not dst_disk_->is_on()))
-      set_state(State::FAILED);
-    else
-      set_state(State::CANCELED);
-  } else if (timeout_detector_ && timeout_detector_->get_state() == resource::Action::State::FINISHED &&
-             model_action_->get_remains() > 0.0) {
-    model_action_->set_state(resource::Action::State::FAILED);
-    set_state(State::TIMEOUT);
-  } else {
-    set_state(State::DONE);
-  }
-
-  clean_action();
-  if (timeout_detector_) {
-    timeout_detector_->unref();
-    timeout_detector_ = nullptr;
-  }
-
-  /* Answer all simcalls associated with the synchro */
-  finish();
-}
 void IoImpl::set_exception(actor::ActorImpl* issuer)
 {
   switch (get_state()) {
@@ -168,6 +124,25 @@ void IoImpl::set_exception(actor::ActorImpl* issuer)
 void IoImpl::finish()
 {
   XBT_DEBUG("IoImpl::finish() in state %s", get_state_str());
+  if (model_action_ != nullptr) {
+    performed_ioops_ = model_action_->get_cost();
+    if (model_action_->get_state() == resource::Action::State::FAILED) {
+      if (host_ && dst_host_) { // this is an I/O stream
+        if (not host_->is_on())
+          set_state(State::SRC_HOST_FAILURE);
+        else if (not dst_host_->is_on())
+          set_state(State::DST_HOST_FAILURE);
+      } else if ((disk_ && not disk_->is_on()) || (dst_disk_ && not dst_disk_->is_on()))
+        set_state(State::FAILED);
+      else
+        set_state(State::CANCELED);
+    } else {
+      set_state(State::DONE);
+    }
+
+    clean_action();
+  }
+
   while (not simcalls_.empty()) {
     actor::Simcall* simcall = simcalls_.front();
     simcalls_.pop_front();