Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[surf] Change routing_parse_init() into routing_add_host()
[simgrid.git] / src / surf / storage_n11.cpp
index 7d73325..01769e1 100644 (file)
@@ -214,7 +214,7 @@ void surf_storage_model_init_default(void)
 {
   surf_storage_model = new StorageN11Model();
   storage_define_callbacks();
-  xbt_dynar_push(model_list, &surf_storage_model);
+  xbt_dynar_push(all_existing_models, &surf_storage_model);
 }
 
 StorageN11Model::StorageN11Model() : StorageModel() {
@@ -252,7 +252,7 @@ Storage *StorageN11Model::createStorage(const char* id, const char* type_id,
   Storage *storage = new StorageN11(this, id, properties, p_maxminSystem,
       Bread, Bwrite, Bconnection, type_id, (char *)content_name,
       xbt_strdup(content_type), storage_type->size, (char *) attach);
-
+  surf_callback_emit(storageCreatedCallbacks, storage);
   xbt_lib_set(storage_lib, id, SURF_STORAGE_LEVEL, storage);
 
   XBT_DEBUG("SURF storage create resource\n\t\tid '%s'\n\t\ttype '%s'\n\t\tproperties '%p'\n\t\tBread '%f'\n",
@@ -433,7 +433,11 @@ StorageAction *StorageN11::close(surf_file_t fd)
 StorageAction *StorageN11::read(surf_file_t fd, sg_size_t size)
 {
   if(fd->current_position + size > fd->size){
-    size = fd->size - fd->current_position;
+    if (fd->current_position > fd->size){
+      size = 0;
+    } else {
+      size = fd->size - fd->current_position;
+    }
     fd->current_position = fd->size;
   }
   else
@@ -498,7 +502,7 @@ int StorageN11Action::unref()
 {
   m_refcount--;
   if (!m_refcount) {
-       if (actionHook::is_linked())
+       if (action_hook.is_linked())
          p_stateSet->erase(p_stateSet->iterator_to(*this));
     if (getVariable())
       lmm_variable_free(getModel()->getMaxminSystem(), getVariable());