From: Frederic Suter Date: Mon, 25 Jul 2016 13:21:45 +0000 (+0200) Subject: fix issue raised by kenenbek X-Git-Tag: v3_14~718 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/4894cf99d6de1692c325bb49e79e02dbe7a56b8d?ds=sidebyside fix issue raised by kenenbek is one attempts to read an empty file, or write 0 byte in a file, return immediatly. if the I/O operation is remote, it would lead to a 0-flop-0-byte parallel task, which is not allowed. --- diff --git a/src/msg/msg_io.cpp b/src/msg/msg_io.cpp index 4b0c1ce0b0..31d0bb17e9 100644 --- a/src/msg/msg_io.cpp +++ b/src/msg/msg_io.cpp @@ -94,6 +94,9 @@ sg_size_t MSG_file_read(msg_file_t fd, sg_size_t size) msg_file_priv_t file_priv = MSG_file_priv(fd); sg_size_t read_size; + if (file_priv->size == 0.0) /* Nothing to read, return */ + return 0.0; + /* Find the host where the file is physically located and read it */ msg_storage_t storage_src =(msg_storage_t) xbt_lib_get_elm_or_null(storage_lib, file_priv->storageId); msg_storage_priv_t storage_priv_src = MSG_storage_priv(storage_src); @@ -108,7 +111,7 @@ sg_size_t MSG_file_read(msg_file_t fd, sg_size_t size) m_host_list[0] = MSG_host_self(); m_host_list[1] = attached_host; - double flops_amount[] = { 0, 0 }; + double flops_amount[] = { 0, 0}; double bytes_amount[] = { 0, 0, (double)read_size, 0 }; msg_task_t task = MSG_parallel_task_create("file transfer for read", 2, m_host_list, flops_amount, bytes_amount, @@ -139,6 +142,9 @@ sg_size_t MSG_file_write(msg_file_t fd, sg_size_t size) { msg_file_priv_t file_priv = MSG_file_priv(fd); + if (size == 0.0) /* Nothing to write, return */ + return 0.0; + /* Find the host where the file is physically located (remote or local)*/ msg_storage_t storage_src =(msg_storage_t) xbt_lib_get_elm_or_null(storage_lib, file_priv->storageId); msg_storage_priv_t storage_priv_src = MSG_storage_priv(storage_src);