Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
s/HAVE_SENDFILE/SG_HAVE_SENDFILE/
[simgrid.git] / src / smpi / internals / smpi_global.cpp
index dcc7d0f..c337d3e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2018. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -37,7 +37,7 @@
 # define HAVE_WORKING_MMAP 1
 #endif
 
-#if HAVE_SENDFILE
+#if SG_HAVE_SENDFILE
 #include <sys/sendfile.h>
 #endif
 
@@ -498,7 +498,7 @@ static void smpi_copy_file(std::string src, std::string target, off_t fdin_size)
 
   XBT_DEBUG("Copy %" PRIdMAX " bytes into %s", static_cast<intmax_t>(fdin_size), target.c_str());
   bool slow_copy = true;
-#if HAVE_SENDFILE
+#if SG_HAVE_SENDFILE
   ssize_t sent_size = sendfile(fdout, fdin, NULL, fdin_size);
   if (sent_size == fdin_size)
     slow_copy = false;
@@ -563,7 +563,7 @@ static void smpi_init_privatization_dlopen(const std::string& executable)
       void* libhandle = dlopen(libname.c_str(), RTLD_LAZY);
       // get library name from path
       char fullpath[512] = {'\0'};
-      strcpy(fullpath, libname.c_str());
+      strncpy(fullpath, libname.c_str(), 511);
 #if not defined(__APPLE__)
       int ret = dl_iterate_phdr(visit_libs, fullpath);
       if (ret == 0)
@@ -673,12 +673,6 @@ int smpi_main(const char* executable, int argc, char* argv[])
 
   SMPI_switch_data_segment = &smpi_switch_data_segment;
 
-  // TODO This will not be executed in the case where smpi_main is not called,
-  // e.g., not for smpi_msg_masterslave. This should be moved to another location
-  // that is always called -- maybe close to Actor::on_creation?
-  simgrid::s4u::Host::on_creation.connect(
-      [](simgrid::s4u::Host& host) { host.extension_set(new simgrid::smpi::Host(&host)); });
-
   // parse the platform file: get the host list
   simgrid::s4u::Engine::get_instance()->load_platform(argv[1]);
   SIMIX_comm_set_copy_data_callback(smpi_comm_copy_buffer_callback);
@@ -739,6 +733,8 @@ void SMPI_init(){
       process_data.erase(it);
     }
   });
+  simgrid::s4u::Host::on_creation.connect(
+      [](simgrid::s4u::Host& host) { host.extension_set(new simgrid::smpi::Host(&host)); });
 
   smpi_init_options();
   smpi_global_init();