diff --git a/cmake/OS_Detection.cmake b/cmake/OS_Detection.cmake index fa5457b717fb4f32c68d5df248b4113a322c9860..00138df46e8b95f9b55305ee5dc5e36fd7939654 100644 --- a/cmake/OS_Detection.cmake +++ b/cmake/OS_Detection.cmake @@ -69,11 +69,12 @@ if(UNIX) endif() if (BSD) if(DAP_DEBUG) - set(_CCOPT "-I/usr/local/include -DDAP_DEBUG -Wall -Wno-deprecated-declarations -Wno-unused-local-typedefs -Wno-unused-function -Wno-implicit-fallthrough -Wno-unused-variable -Wno-unused-parameter -pg -g3 -ggdb -fno-eliminate-unused-debug-symbols -fno-strict-aliasing") - set(_LOPT "-pg") + set(_CCOPT "-L/usr/local/lib -I/usr/local/include -DDAP_DEBUG -Wall -Wno-deprecated-declarations -Wno-unused-local-typedefs -Wno-unused-function -Wno-implicit-fallthrough -Wno-unused-variable -Wno-unused-parameter -pg -g3 -ggdb -fno-eliminate-unused-debug-symbols -fno-strict-aliasing") + set(_LOPT "-pg -L/usr/local/lib ") SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pg") else() - set(_CCOPT "-I/usr/local/include -Wno-deprecated-declarations -Wno-unused-local-typedefs -Wno-unused-function -Wno-implicit-fallthrough -Wno-unused-variable -Wno-unused-parameter -O3 -fPIC -fno-strict-aliasing -fno-ident -ffast-math -ftree-vectorize -fno-asynchronous-unwind-tables -ffunction-sections -std=gnu11") + set(_CCOPT "-L/usr/local/lib -I/usr/local/include -Wno-deprecated-declarations -Wno-unused-local-typedefs -Wno-unused-function -Wno-implicit-fallthrough -Wno-unused-variable -Wno-unused-parameter -O3 -fPIC -fno-strict-aliasing -fno-ident -ffast-math -ftree-vectorize -fno-asynchronous-unwind-tables -ffunction-sections -std=gnu11") + set(_LOPT "-L/usr/local/lib ") endif() endif() diff --git a/dap-sdk/core/src/unix/dap_process_manager.c b/dap-sdk/core/src/unix/dap_process_manager.c index e2d825977374cc7f46056d74677ddada73aef97f..2a853e6ee0535f69908632ba783538546f6720ae 100755 --- a/dap-sdk/core/src/unix/dap_process_manager.c +++ b/dap-sdk/core/src/unix/dap_process_manager.c @@ -1,4 +1,4 @@ -#ifdef __linux__ +#ifdef DAP_OS_UNIX #include <stdio.h> #include <sys/types.h> #include <signal.h> diff --git a/dap-sdk/core/src/unix/dap_process_manager.h b/dap-sdk/core/src/unix/dap_process_manager.h index 29fb0ddcc86e6bbb67acda0bd9f5dda65f3ccb39..e703c8b834ca503d24df0e21d150cbedc5fcfac2 100755 --- a/dap-sdk/core/src/unix/dap_process_manager.h +++ b/dap-sdk/core/src/unix/dap_process_manager.h @@ -28,7 +28,7 @@ extern "C" { #endif -#ifdef __linux__ +#ifdef DAP_OS_UNIX #include <stdbool.h> #include <unistd.h> diff --git a/dap-sdk/net/core/dap_proc_thread.c b/dap-sdk/net/core/dap_proc_thread.c index 260428d710ee19fcbd8aa0858c5036caa1368954..8bbce7c5dee6fa09a8c6a38531ae248bd12c4a68 100644 --- a/dap-sdk/net/core/dap_proc_thread.c +++ b/dap-sdk/net/core/dap_proc_thread.c @@ -178,6 +178,12 @@ static void s_proc_event_callback(dap_events_socket_t * a_esocket, uint64_t a_va // log_it(L_DEBUG, "<-- Proc event callback end"); } + +int dap_proc_thread_assign_esocket_unsafe( dap_proc_thread_t* a_thread, dap_events_socket_t * a_esocket ) +{ + return dap_proc_thread_esocket_update_poll_flags(a_thread,a_esocket); +} + /** * @brief dap_proc_thread_assign_esocket_unsafe * @param a_thread @@ -257,6 +263,12 @@ int dap_proc_thread_esocket_update_poll_flags(dap_proc_thread_t * a_thread, dap_ return -1; } #elif defined (DAP_EVENTS_CAPS_POLL) + if ( a_thread->poll_count == a_thread->poll_count_max ){ // realloc + a_thread->poll_count_max *= 2; + log_it(L_WARNING, "Too many descriptors (%u), resizing array twice to %u", a_thread->poll_count, a_thread->poll_count_max); + a_thread->poll =DAP_REALLOC(a_thread->poll, a_thread->poll_count_max * sizeof(*a_thread->poll)); + a_thread->poll_esocket =DAP_REALLOC(a_thread->poll_esocket, a_thread->poll_count_max * sizeof(*a_thread->poll_esocket)); + } a_thread->poll[a_esocket->poll_index].events= a_esocket->poll_base_flags; if( a_esocket->flags & DAP_SOCK_READY_TO_READ) a_thread->poll[a_esocket->poll_index].revents |= POLLIN; diff --git a/modules/net/CMakeLists.txt b/modules/net/CMakeLists.txt index 3c1b2a9d5af628be26818201d20d3b31dc5e38db..d64767b6181ae6aec139d0dc0c65d1f0ed77b055 100644 --- a/modules/net/CMakeLists.txt +++ b/modules/net/CMakeLists.txt @@ -41,12 +41,16 @@ if(WIN32) dap_chain_mempool dap_chain_global_db dap_chain_net_srv_stake dap_chain_cs_none) endif() -if(UNIX) +if(LINUX) target_link_libraries(${PROJECT_NAME} dap_core dap_crypto dap_client dap_stream_ch_chain dap_stream_ch_chain_net dap_stream_ch_chain_net_srv dap_chain dap_chain_wallet dap_chain_net_srv dap_chain_mempool dap_chain_global_db dap_chain_net_srv_stake dap_chain_cs_none resolv ) +elseif(BSD) + target_link_libraries(${PROJECT_NAME} dap_core dap_crypto dap_client dap_stream_ch_chain dap_stream_ch_chain_net dap_stream_ch_chain_net_srv dap_chain + dap_chain_wallet dap_chain_net_srv dap_chain_mempool dap_chain_global_db dap_chain_net_srv_stake dap_chain_cs_none ) endif() + target_include_directories(${PROJECT_NAME} INTERFACE . ) target_include_directories(${PROJECT_NAME} PUBLIC include) target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../3rdparty/uthash/src) diff --git a/modules/net/dap_chain_node_cli_cmd.c b/modules/net/dap_chain_node_cli_cmd.c index 66a3ec2f72b2d10878b57ef4f61d3c5841809cd4..41a6d8d0fc2b4a221b81f3ee70d2d74a4d2231ac 100644 --- a/modules/net/dap_chain_node_cli_cmd.c +++ b/modules/net/dap_chain_node_cli_cmd.c @@ -1274,7 +1274,7 @@ int com_node(int a_argc, char ** a_argv, void *arg_func, char **a_str_reply) */ int com_traceroute(int argc, char** argv, void *arg_func, char **str_reply) { -#ifndef _WIN32 +#ifdef DAP_OS_LINUX const char *addr = NULL; int hops = 0, time_usec = 0; if(argc > 1) @@ -1342,8 +1342,10 @@ int com_traceroute(int argc, char** argv, void *arg_func, char **str_reply) } } return res; +#else + dap_chain_node_cli_set_reply_text(str_reply, "Not realized for your platform"); + return -1; #endif - return 0; } /** @@ -1353,7 +1355,7 @@ int com_traceroute(int argc, char** argv, void *arg_func, char **str_reply) */ int com_tracepath(int argc, char** argv, void *arg_func, char **str_reply) { -#ifndef _WIN32 +#ifdef DAP_OS_LINUX const char *addr = NULL; int hops = 0, time_usec = 0; if(argc > 1) @@ -1416,8 +1418,10 @@ int com_tracepath(int argc, char** argv, void *arg_func, char **str_reply) } } return res; +#else + dap_chain_node_cli_set_reply_text(str_reply, "Not realized for your platform"); + return -1; #endif - return 0; } /** @@ -1427,7 +1431,7 @@ int com_tracepath(int argc, char** argv, void *arg_func, char **str_reply) */ int com_ping(int argc, char** argv, void *arg_func, char **str_reply) { -#ifndef _WIN32 +#ifdef DAP_OS_LINUX int n = 4; if(argc < 2) { @@ -1480,8 +1484,10 @@ int com_ping(int argc, char** argv, void *arg_func, char **str_reply) } } return res; +#else + dap_chain_node_cli_set_reply_text(str_reply, "Not realized for your platform"); + return -1; #endif - return 0; } /** diff --git a/modules/net/dap_chain_node_ping.c b/modules/net/dap_chain_node_ping.c index e21b1bc78389b5698eec6d4bb9d3f47d5045c103..353bf48fe476ce73cd43c8d7a77d6cca992037a0 100644 --- a/modules/net/dap_chain_node_ping.c +++ b/modules/net/dap_chain_node_ping.c @@ -217,7 +217,7 @@ static void* node_ping_background_proc(void *a_arg) if(!str_ip4) continue; int hops = 0, time_usec = 0; -#ifndef _WIN32 +#ifdef DAP_OS_LINUX int res = traceroute_util(str_ip4, &hops, &time_usec); #endif DAP_DELETE(host4);