From ca7ea486ca62191e82cb7e7e47e538e07d7524dc Mon Sep 17 00:00:00 2001 From: Dmitry Gerasimov <dmitriy.gerasimov@demlabs.net> Date: Wed, 8 Jun 2022 20:32:04 +0700 Subject: [PATCH] [*] Some minor fixes after previous merges --- cmake/OS_Detection.cmake | 30 ++++++++++++++++---------- dap-sdk/io/dap_context.c | 7 +++--- dap-sdk/io/dap_events_socket.c | 3 ++- dap-sdk/io/include/dap_events_socket.h | 1 - 4 files changed, 24 insertions(+), 17 deletions(-) diff --git a/cmake/OS_Detection.cmake b/cmake/OS_Detection.cmake index 9a1ceddf89..590a6a6f42 100644 --- a/cmake/OS_Detection.cmake +++ b/cmake/OS_Detection.cmake @@ -83,6 +83,8 @@ if(UNIX) endif() if (LINUX) + set(CCOPT_SYSTEM "") + set(LDOPT_SYSTEM "") if(DAP_DEBUG) set(_CCOPT "-DDAP_DEBUG -Wall -Wno-unused-command-line-argument -Wno-deprecated-declarations -Wno-unused-local-typedefs -Wno-unused-function -Wno-implicit-fallthrough -Wno-unused-variable -Wno-unused-parameter -Wno-unused-but-set-variable -pg -g3 -ggdb -fno-eliminate-unused-debug-symbols -fno-strict-aliasing") set(_LOPT "-pg") @@ -91,24 +93,28 @@ if(UNIX) set(_CCOPT "-Wno-deprecated-declarations -Wno-unused-command-line-argument -Wno-unused-local-typedefs -Wno-unused-function -Wno-implicit-fallthrough -Wno-unused-variable -Wno-unused-parameter -Wno-unused-but-set-variable -O3 -fPIC -fno-strict-aliasing -fno-ident -ffast-math -ftree-vectorize -fno-asynchronous-unwind-tables -ffunction-sections -Wl,--gc-sections -Wl,--strip-all -std=gnu11") endif() elseif (DARWIN) + set(CCOPT_SYSTEM "-L/usr/local/lib -L/opt/homebrew/lib -I/opt/homebrew/include -I/usr/local/include") + set(LDOPT_SYSTEM "-L/usr/local/lib -L/opt/homebrew/lib -lintl") if(DAP_DEBUG) - set(_CCOPT "-L/usr/local/lib -L/opt/homebrew/lib -I/opt/homebrew/include -I/usr/local/include -DDAP_DEBUG -Wall -Wno-address-of-packed-member -Wno-unused-command-line-argument -Wno-deprecated-declarations -Wno-unused-local-typedefs -Wno-unused-function -Wno-implicit-fallthrough -Wno-unused-variable -Wno-unused-parameter -g3 -ggdb -fno-eliminate-unused-debug-symbols -fno-strict-aliasing -std=c11") - set(_LOPT "-L/usr/local/lib -L/opt/homebrew/lib") + set(_CCOPT "${CCOPT_SYSTEM} -DDAP_DEBUG -Wall -Wno-address-of-packed-member -Wno-unused-command-line-argument -Wno-deprecated-declarations -Wno-unused-local-typedefs -Wno-unused-function -Wno-implicit-fallthrough -Wno-unused-variable -Wno-unused-parameter -g3 -ggdb -fno-eliminate-unused-debug-symbols -fno-strict-aliasing -std=c11") + set(_LOPT "${LDOPT_SYSTEM}") SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") else() - set(_CCOPT "-L/usr/local/lib -L/opt/homebrew/lib -I/opt/homebrew/include -I/usr/local/include -Wno-address-of-packed-member -Wno-deprecated-declarations -Wno-unused-command-line-argument -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=c11") - set(_LOPT "-L/usr/local/lib -L/opt/homebrew/lib") - SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L/opt/homebrew/lib -L/usr/local/lib") + set(_CCOPT "${CCOPT_SYSTEM} -Wno-address-of-packed-member -Wno-deprecated-declarations -Wno-unused-command-line-argument -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=c11") + set(_LOPT "${LDOPT_SYSTEM}") + SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") endif() elseif(BSD) + set(CCOPT_SYSTEM "-L/usr/local/lib -I/usr/local/include") + set(LDOPT_SYSTEM "-L/usr/local/lib") if(DAP_DEBUG) - set(_CCOPT "-L/usr/local/lib -I/usr/local/include -DDAP_DEBUG -Wall -Wno-unused-command-line-argument -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(_CCOPT "${CCOPT_SYSTEM} -DDAP_DEBUG -Wall -Wno-unused-command-line-argument -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 ${LDOPT_SYSTEM} ") SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pg") else() - set(_CCOPT "-L /usr/local/lib -I/usr/local/include -Wno-deprecated-declarations -Wno-unused-command-line-argument -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 ") - SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L/usr/local/lib") + set(_CCOPT "${CCOPT_SYSTEM} -Wno-deprecated-declarations -Wno-unused-command-line-argument -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 "${LDOPT_SYSTEM} ") + SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") endif() endif() @@ -142,8 +148,10 @@ if(WIN32) add_definitions("-DNGHTTP2_STATICLIB") add_compile_definitions(WINVER=0x0600 _WIN32_WINNT=0x0600) add_definitions ("-DDAP_OS_WINDOWS") + set(CCOPT_SYSTEM "") + set(LDOPT_SYSTEM "") - if(DAP_DEBUG) + if(DAP_DEBUG) set(_CCOPT "-mconsole -static -Wall -std=gnu11 -Wextra -Wno-deprecated-declarations -Wno-unused-local-typedefs -Wno-unused-function -Wno-implicit-fallthrough -Wno-unused-variable -Wno-unused-parameter -Wno-unused-but-set-variable -g3 -ggdb -fno-strict-aliasing -fno-eliminate-unused-debug-symbols -pg") set(_LOPT "-mconsole -static -pg") else() diff --git a/dap-sdk/io/dap_context.c b/dap-sdk/io/dap_context.c index 254c2c9366..36b1d104b8 100644 --- a/dap-sdk/io/dap_context.c +++ b/dap-sdk/io/dap_context.c @@ -1271,19 +1271,18 @@ int dap_context_add_esocket(dap_context_t * a_context, dap_events_socket_t * a_e log_it(L_ERROR,"Can't update client socket state on kqueue fd %d: \"%s\" (%d)", a_esocket->socket, l_errbuf, l_errno); return l_errno; - }else{ - a_esocket->context = a_context; - return 0; } + #else #error "Unimplemented new esocket on context callback for current platform" #endif + a_esocket->context = a_context; // Add in context HT - a_esocket->me = a_esocket; if (a_esocket->socket!=0 && a_esocket->socket != INVALID_SOCKET){ HASH_ADD(hh, a_context->esockets, uuid, sizeof(a_esocket->uuid), a_esocket ); a_context->event_sockets_count++; } + return 0; } diff --git a/dap-sdk/io/dap_events_socket.c b/dap-sdk/io/dap_events_socket.c index 56d8f4ff71..44e4e0f096 100644 --- a/dap-sdk/io/dap_events_socket.c +++ b/dap-sdk/io/dap_events_socket.c @@ -1312,7 +1312,8 @@ void dap_events_socket_remove_from_worker_unsafe( dap_events_socket_t *a_es, dap } a_worker->context->event_sockets_count--; - HASH_DELETE(hh,a_worker->context->esockets, a_es); + if(a_es->socket != 0 && a_es->socket != INVALID_SOCKET ) + HASH_DELETE(hh,a_worker->context->esockets, a_es); #if defined(DAP_EVENTS_CAPS_EPOLL) diff --git a/dap-sdk/io/include/dap_events_socket.h b/dap-sdk/io/include/dap_events_socket.h index 5d8356eff8..95f17cbd0d 100644 --- a/dap-sdk/io/include/dap_events_socket.h +++ b/dap-sdk/io/include/dap_events_socket.h @@ -276,7 +276,6 @@ typedef struct dap_events_socket { void *_inheritor; // Inheritor data to specific client type, usualy states for state machine void *_pvt; //Private section, different for different types - struct dap_events_socket * me; // pointer on itself UT_hash_handle hh; // Handle for local CPU storage on worker or proc_thread } dap_events_socket_t; // Node of bidirectional list of clients -- GitLab