Skip to content

Commit

Permalink
Fix missing entrypoints
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Jul 3, 2024
1 parent 132fc5f commit fa9180f
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 12 deletions.
4 changes: 1 addition & 3 deletions nano/core_test/entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

#include <boost/filesystem/path.hpp>

constexpr std::size_t OPEN_FILE_DESCRIPTORS_LIMIT = 16384;

namespace nano
{
namespace test
Expand All @@ -19,8 +17,8 @@ void force_nano_dev_network ();

GTEST_API_ int main (int argc, char ** argv)
{
nano::initialize_file_descriptor_limit ();
nano::logger::initialize_for_tests (nano::log_config::tests_default ());
nano::set_file_descriptor_limit (OPEN_FILE_DESCRIPTORS_LIMIT);
nano::force_nano_dev_network ();
nano::node_singleton_memory_pool_purge_guard memory_pool_cleanup_guard;
testing::InitGoogleTest (&argc, argv);
Expand Down
10 changes: 10 additions & 0 deletions nano/lib/utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ void nano::set_file_descriptor_limit (std::size_t limit)
#endif
}

void nano::initialize_file_descriptor_limit ()
{
nano::set_file_descriptor_limit (DEFAULT_FILE_DESCRIPTOR_LIMIT);
auto limit = nano::get_file_descriptor_limit ();
if (limit < DEFAULT_FILE_DESCRIPTOR_LIMIT)
{
std::cerr << "WARNING: Current file descriptor limit of " << limit << " is lower than the " << DEFAULT_FILE_DESCRIPTOR_LIMIT << " recommended. Node was unable to change it." << std::endl;
}
}

nano::container_info_composite::container_info_composite (std::string const & name) :
name (name)
{
Expand Down
5 changes: 5 additions & 0 deletions nano/lib/utility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ void create_load_memory_address_files ();
*/
std::size_t get_file_descriptor_limit ();
void set_file_descriptor_limit (std::size_t limit);
/**
* This should be called from entry points. It sets the file descriptor limit to the maximum allowed and logs any errors.
*/
constexpr std::size_t DEFAULT_FILE_DESCRIPTOR_LIMIT = 16384;
void initialize_file_descriptor_limit ();

void remove_all_files_in_dir (std::filesystem::path const & dir);
void move_all_files_to_dir (std::filesystem::path const & from, std::filesystem::path const & to);
Expand Down
10 changes: 1 addition & 9 deletions nano/nano_node/entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,14 @@ class address_library_pair
bool operator== (const address_library_pair & other) const;
};

constexpr std::size_t OPEN_FILE_DESCRIPTORS_LIMIT = 16384;
}

int main (int argc, char * const * argv)
{
nano::set_umask (); // Make sure the process umask is set before any files are created
nano::initialize_file_descriptor_limit ();
nano::logger::initialize (nano::log_config::cli_default ());

// Increase file descriptor limit
nano::set_file_descriptor_limit (OPEN_FILE_DESCRIPTORS_LIMIT);
auto const file_descriptor_limit = nano::get_file_descriptor_limit ();
if (file_descriptor_limit < OPEN_FILE_DESCRIPTORS_LIMIT)
{
std::cerr << "WARNING: Current file descriptor limit of " << file_descriptor_limit << " is lower than the " << OPEN_FILE_DESCRIPTORS_LIMIT << " recommended. Node was unable to change it." << std::endl;
}

nano::node_singleton_memory_pool_purge_guard memory_pool_cleanup_guard;

boost::program_options::options_description description ("Command line options");
Expand Down
1 change: 1 addition & 0 deletions nano/nano_rpc/entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ void run (std::filesystem::path const & data_path, std::vector<std::string> cons
int main (int argc, char * const * argv)
{
nano::set_umask (); // Make sure the process umask is set before any files are created
nano::initialize_file_descriptor_limit ();
nano::logger::initialize (nano::log_config::cli_default ());

boost::program_options::options_description description ("Command line options");
Expand Down
1 change: 1 addition & 0 deletions nano/nano_wallet/entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ int run_wallet (QApplication & application, int argc, char * const * argv, std::
int main (int argc, char * const * argv)
{
nano::set_umask (); // Make sure the process umask is set before any files are created
nano::initialize_file_descriptor_limit ();
nano::logger::initialize (nano::log_config::cli_default ());

nano::node_singleton_memory_pool_purge_guard memory_pool_cleanup_guard;
Expand Down
1 change: 1 addition & 0 deletions nano/qt_test/entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ void force_nano_dev_network ();

int main (int argc, char ** argv)
{
nano::initialize_file_descriptor_limit ();
nano::logger::initialize_for_tests (nano::log_config::tests_default ());
nano::force_nano_dev_network ();
nano::node_singleton_memory_pool_purge_guard memory_pool_cleanup_guard;
Expand Down
1 change: 1 addition & 0 deletions nano/rpc_test/entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ void force_nano_dev_network ();

int main (int argc, char ** argv)
{
nano::initialize_file_descriptor_limit ();
nano::logger::initialize_for_tests (nano::log_config::tests_default ());
nano::force_nano_dev_network ();
nano::set_use_memory_pools (false);
Expand Down
1 change: 1 addition & 0 deletions nano/slow_test/entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ void force_nano_dev_network ();

int main (int argc, char ** argv)
{
nano::initialize_file_descriptor_limit ();
nano::logger::initialize_for_tests (nano::log_config::tests_default ());
nano::force_nano_dev_network ();
nano::node_singleton_memory_pool_purge_guard memory_pool_cleanup_guard;
Expand Down

0 comments on commit fa9180f

Please sign in to comment.