From dce3c1b9a37a3489b56a9b5fc9fc2f10a7bc5f79 Mon Sep 17 00:00:00 2001 From: suter Date: Fri, 23 May 2014 19:47:49 +0200 Subject: [PATCH] allow several hosts to open the same file simultaneously --- src/msg/msg_io.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/msg/msg_io.c b/src/msg/msg_io.c index d5e169091b..d4a0d4e4bb 100644 --- a/src/msg/msg_io.c +++ b/src/msg/msg_io.c @@ -187,13 +187,15 @@ sg_size_t MSG_file_write(msg_file_t fd, sg_size_t size) */ msg_file_t MSG_file_open(const char* fullpath, void* data) { + char name[2048]; msg_file_priv_t priv = xbt_new(s_msg_file_priv_t, 1); priv->data = data; priv->fullpath = xbt_strdup(fullpath); priv->simdata = xbt_new0(s_simdata_file_t,1); priv->simdata->smx_file = simcall_file_open(fullpath, MSG_host_self()); - xbt_lib_set(file_lib, fullpath, MSG_FILE_LEVEL, priv); - msg_file_t fd = (msg_file_t) xbt_lib_get_elm_or_null(file_lib, fullpath); + sprintf(name, "%s:%s",MSG_host_get_name(MSG_host_self()),fullpath); + xbt_lib_set(file_lib, name, MSG_FILE_LEVEL, priv); + msg_file_t fd = (msg_file_t) xbt_lib_get_elm_or_null(file_lib, name); __MSG_file_get_info(fd); return fd; @@ -216,9 +218,11 @@ void __MSG_file_priv_free(msg_file_priv_t priv) */ int MSG_file_close(msg_file_t fd) { + char name[2048]; msg_file_priv_t priv = MSG_file_priv(fd); int res = simcall_file_close(priv->simdata->smx_file, MSG_host_self()); - xbt_lib_unset(file_lib, priv->fullpath, MSG_FILE_LEVEL, 1); + sprintf(name, "%s:%s",MSG_host_get_name(MSG_host_self()),priv->fullpath); + xbt_lib_unset(file_lib, name, MSG_FILE_LEVEL, 1); return res; } -- 2.20.1