From 453963479a50212e7a555cf60b7c4e0cf64e3df6 Mon Sep 17 00:00:00 2001 From: Dmitriy Gerasimov <naeper@demlabs.net> Date: Sun, 14 Feb 2021 18:09:59 +0700 Subject: [PATCH] [-] Switched off VPN service for BSD build, until smbd port TUN driver operations for BSD --- cmake/OS_Detection.cmake | 7 ++++--- dap-sdk/core/src/unix/dap_process_manager.c | 2 +- dap-sdk/core/src/unix/dap_process_manager.h | 2 +- dap-sdk/net/core/dap_proc_thread.c | 12 ++++++++++++ dap-sdk/net/core/include/dap_proc_thread.h | 2 +- modules/net/CMakeLists.txt | 6 +++++- modules/net/dap_chain_node_cli_cmd.c | 18 ++++++++++++------ modules/net/dap_chain_node_ping.c | 2 +- 8 files changed, 37 insertions(+), 14 deletions(-) diff --git a/cmake/OS_Detection.cmake b/cmake/OS_Detection.cmake index fa5457b717..00138df46e 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 e2d8259773..2a853e6ee0 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 29fb0ddcc8..e703c8b834 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 87108fc04c..23425e7633 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_esocket_update_poll_flags * @param a_thread @@ -209,6 +215,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/dap-sdk/net/core/include/dap_proc_thread.h b/dap-sdk/net/core/include/dap_proc_thread.h index 12a7fc0ab4..caf4ea2e5a 100644 --- a/dap-sdk/net/core/include/dap_proc_thread.h +++ b/dap-sdk/net/core/include/dap_proc_thread.h @@ -80,4 +80,4 @@ typedef void (*dap_proc_worker_callback_t)(dap_worker_t *,void *); void dap_proc_thread_worker_exec_callback(dap_proc_thread_t * a_thread, size_t a_worker_id, dap_proc_worker_callback_t a_callback, void * a_arg); -dap_proc_thread_t * dap_proc_thread_assign_esocket_unsafe(dap_proc_thread_t * a_thread, dap_events_socket_t * a_esocket); +int dap_proc_thread_assign_esocket_unsafe(dap_proc_thread_t * a_thread, dap_events_socket_t * a_esocket); diff --git a/modules/net/CMakeLists.txt b/modules/net/CMakeLists.txt index 3c1b2a9d5a..d64767b618 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 66a3ec2f72..41a6d8d0fc 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 e21b1bc783..353bf48fe4 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); -- GitLab