From: Frederic Suter Date: Mon, 26 Jun 2017 09:22:46 +0000 (+0200) Subject: plug leak of file unlink X-Git-Tag: v3_17~517^2 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/f05e94875ba4e3844da6824b91b8258179a90d08 plug leak of file unlink --- diff --git a/examples/msg/io-file/io-file.c b/examples/msg/io-file/io-file.c index 3e9d2728e9..4f7f0799ec 100644 --- a/examples/msg/io-file/io-file.c +++ b/examples/msg/io-file/io-file.c @@ -76,10 +76,10 @@ static int host(int argc, char *argv[]) filename, MSG_storage_get_used_size(st), MSG_storage_get_size(st)); if (MSG_process_self_PID() == 1){ - XBT_INFO("\tUnlink file '%s'",MSG_file_get_name(file)); + XBT_INFO("\tUnlink file '%s'", MSG_file_get_name(file)); MSG_file_unlink(file); } else { - XBT_INFO("\tClose file '%s'",filename); + XBT_INFO("\tClose file '%s'", filename); MSG_file_close(file); } return 0; diff --git a/src/msg/msg_io.cpp b/src/msg/msg_io.cpp index b636be848d..a37a312db1 100644 --- a/src/msg/msg_io.cpp +++ b/src/msg/msg_io.cpp @@ -204,6 +204,7 @@ msg_error_t MSG_file_unlink(msg_file_t fd) msg_storage_t storage_src = simgrid::s4u::Storage::byName(fd->storageId); msg_host_t attached_host = storage_src->host(); fd->unlink(attached_host); + delete fd; return MSG_OK; } diff --git a/src/simix/smx_io.cpp b/src/simix/smx_io.cpp index e033cb90b6..eb041ecc8a 100644 --- a/src/simix/smx_io.cpp +++ b/src/simix/smx_io.cpp @@ -117,9 +117,7 @@ int SIMIX_file_unlink(smx_file_t fd, sg_host_t host) if (host->isOff()) THROWF(host_error, 0, "Host %s failed, you cannot call this function", host->cname()); - int res = surf_host_unlink(host, fd->surf_file); - xbt_free(fd); - return res; + return surf_host_unlink(host, fd->surf_file); } sg_size_t simcall_HANDLER_file_get_size(smx_simcall_t simcall, smx_file_t fd) diff --git a/src/surf/HostImpl.cpp b/src/surf/HostImpl.cpp index 2cb9e021f2..fa047d27f9 100644 --- a/src/surf/HostImpl.cpp +++ b/src/surf/HostImpl.cpp @@ -152,9 +152,6 @@ int HostImpl::unlink(surf_file_t fd) // Remove the file from storage st->content_->erase(fd->name); - xbt_free(fd->name); - xbt_free(fd->mount); - xbt_free(fd); return 0; } }