Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
plug leak of file unlink
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 26 Jun 2017 09:22:46 +0000 (11:22 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 26 Jun 2017 09:22:46 +0000 (11:22 +0200)
examples/msg/io-file/io-file.c
src/msg/msg_io.cpp
src/simix/smx_io.cpp
src/surf/HostImpl.cpp

index 3e9d272..4f7f079 100644 (file)
@@ -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;
index b636be8..a37a312 100644 (file)
@@ -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;
 }
 
index e033cb9..eb041ec 100644 (file)
@@ -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)
index 2cb9e02..fa047d2 100644 (file)
@@ -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;
     }
   }