Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Move simcall out of s4u::File destructor.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 16 Mar 2022 21:09:48 +0000 (22:09 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 16 Mar 2022 22:11:52 +0000 (23:11 +0100)
Please Sonar by not throwing uncaught exceptions in a destructor.

include/simgrid/plugins/file_system.h
src/plugins/file_system/s4u_FileSystem.cpp

index 5ecde65..c3fc6c7 100644 (file)
@@ -110,7 +110,7 @@ public:
 
   static File* open(const std::string& fullpath, void* userdata);
   static File* open(const std::string& fullpath, const_sg_host_t host, void* userdata);
-  void close() { delete this; };
+  void close();
 
   /** Retrieves the path to the file */
   const char* get_path() const { return fullpath_.c_str(); }
index 502d053..be2ab2b 100644 (file)
@@ -104,12 +104,7 @@ File::File(const std::string& fullpath, const_sg_host_t host, void* userdata) :
   });
 }
 
-File::~File()
-{
-  std::vector<int>* desc_table =
-      Host::current()->extension<simgrid::s4u::FileDescriptorHostExt>()->file_descriptor_table.get();
-  kernel::actor::simcall_answered([this, desc_table] { desc_table->push_back(this->desc_id); });
-}
+File::~File() = default;
 
 File* File::open(const std::string& fullpath, void* userdata)
 {
@@ -121,6 +116,14 @@ File* File::open(const std::string& fullpath, const_sg_host_t host, void* userda
   return new File(fullpath, host, userdata);
 }
 
+void File::close()
+{
+  std::vector<int>* desc_table =
+      Host::current()->extension<simgrid::s4u::FileDescriptorHostExt>()->file_descriptor_table.get();
+  kernel::actor::simcall_answered([this, desc_table] { desc_table->push_back(this->desc_id); });
+  delete this;
+}
+
 void File::dump() const
 {
   XBT_INFO("File Descriptor information:\n"