X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/71f8c518d2a8e283e62ed3282c051fb125540c75..f3677661714bf6122d678071c0bd44141417be14:/src/surf/storage_interface.cpp diff --git a/src/surf/storage_interface.cpp b/src/surf/storage_interface.cpp index fb5ac01269..d1c824d2fb 100644 --- a/src/surf/storage_interface.cpp +++ b/src/surf/storage_interface.cpp @@ -26,8 +26,8 @@ StorageModelPtr surf_storage_model = NULL; surf_callback(void, StoragePtr) storageCreatedCallbacks; surf_callback(void, StoragePtr) storageDestructedCallbacks; -surf_callback(void, StoragePtr) storageStateChangedCallbacks; -surf_callback(void, StorageActionPtr) storageActionStateChangedCallbacks; +surf_callback(void, StoragePtr, e_surf_resource_state_t, e_surf_resource_state_t) storageStateChangedCallbacks; +surf_callback(void, StorageActionPtr, e_surf_action_state_t, e_surf_action_state_t) storageActionStateChangedCallbacks; /********* * Model * @@ -72,7 +72,7 @@ Storage::Storage(ModelPtr model, const char *name, xbt_dict_t props, , p_writeActions(xbt_dynar_new(sizeof(ActionPtr),NULL)) { surf_callback_emit(storageCreatedCallbacks, this); p_content = parseContent(content_name); - p_attach = (xbt_strdup(attach)); + p_attach = xbt_strdup(attach); setState(SURF_RESOURCE_ON); XBT_DEBUG("Create resource with Bconnection '%f' Bread '%f' Bwrite '%f' and Size '%llu'", bconnection, bread, bwrite, size); p_constraintRead = lmm_constraint_new(maxminSystem, this, bread); @@ -98,8 +98,9 @@ xbt_dict_t Storage::parseContent(char *filename) FILE *file = NULL; file = surf_fopen(filename, "r"); - xbt_assert(file != NULL, "Cannot open file '%s' (path=%s)", filename, - xbt_str_join(surf_path, ":")); + if (file == NULL) + xbt_die("Cannot open file '%s' (path=%s)", filename, + xbt_str_join(surf_path, ":")); char *line = NULL; size_t len = 0; @@ -107,10 +108,9 @@ xbt_dict_t Storage::parseContent(char *filename) char path[1024]; sg_size_t size; - while ((read = xbt_getline(&line, &len, file)) != -1) { if (read){ - if(sscanf(line,"%s %llu", path, &size) == 2) { + if(sscanf(line,"%s %llu", path, &size) == 2) { m_usedSize += size; sg_size_t *psize = xbt_new(sg_size_t, 1); *psize = size; @@ -138,8 +138,9 @@ void Storage::updateState(tmgr_trace_event_t /*event_type*/, double /*value*/, d void Storage::setState(e_surf_resource_state_t state) { + e_surf_resource_state_t old = Resource::getState(); Resource::setState(state); - surf_callback_emit(storageStateChangedCallbacks, this); + surf_callback_emit(storageStateChangedCallbacks, this, old, state); } xbt_dict_t Storage::getContent() @@ -179,6 +180,7 @@ StorageAction::StorageAction(ModelPtr model, double cost, bool failed, lmm_varia } void StorageAction::setState(e_surf_action_state_t state){ + e_surf_action_state_t old = getState(); Action::setState(state); - surf_callback_emit(storageActionStateChangedCallbacks, this); + surf_callback_emit(storageActionStateChangedCallbacks, this, old, state); }