diff --git a/cmake/OS_Detection.cmake b/cmake/OS_Detection.cmake index 0a73b8c83ba1e58f93839b4963848963395f326b..91be8d2875b0632188abd79bccef5eeb843a1d35 100644 --- a/cmake/OS_Detection.cmake +++ b/cmake/OS_Detection.cmake @@ -34,6 +34,10 @@ if((CMAKE_BUILD_TYPE STREQUAL "Debug") OR (DAP_DEBUG)) else() message("[!] Release build") SET(DAP_RELEASE ON) + if((CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")) + message("[!] Debug symbols ON") + SET(DAP_DBG_INFO ON) + endif() endif() if(CMAKE_SIZEOF_VOID_P EQUAL "8") @@ -92,11 +96,14 @@ if(UNIX) 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") - SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pg") + 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") + SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pg") else() 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") + if(NOT DAP_DBG_INFO) + set(_CCOPT "${_CCOPT} -Wl,--strip-all") + endif() endif() elseif (DARWIN) set(CCOPT_SYSTEM "-L/usr/local/lib -L/opt/homebrew/lib -I/opt/homebrew/include -I/usr/local/include") diff --git a/dap-sdk/core/CMakeLists.txt b/dap-sdk/core/CMakeLists.txt index 51f267c717fc6147883b43ae33f3ecb5179fb672..c22e2af763327bcc9fcb43cc03120280fb6e0f78 100755 --- a/dap-sdk/core/CMakeLists.txt +++ b/dap-sdk/core/CMakeLists.txt @@ -36,6 +36,7 @@ target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/.. #This paths will be used by project-dependent project libraries target_include_directories(${PROJECT_NAME} INTERFACE include/ src/rpmalloc/) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../3rdparty/uthash/src) if(WIN32) include_directories(include/) diff --git a/dap-sdk/core/include/dap_common.h b/dap-sdk/core/include/dap_common.h index 14bd227e47dee60bbb736ac8fcd86098d1706a0f..c7dfb5a5d13eadb58d1a657ae2346f63e8dae941 100755 --- a/dap-sdk/core/include/dap_common.h +++ b/dap-sdk/core/include/dap_common.h @@ -45,7 +45,6 @@ #define atomic_uint _Atomic(uint) #endif - #include <time.h> #ifdef DAP_OS_WINDOWS #include <fcntl.h> @@ -56,7 +55,6 @@ #include <dispatch/dispatch.h> #endif #include "portable_endian.h" -typedef uint8_t byte_t; #define BIT( x ) ( 1 << x ) // Stuffs an integer into a pointer type @@ -274,6 +272,7 @@ DAP_STATIC_INLINE void _dap_aligned_free( void *ptr ) #define dap_vasprintf vasprintf #endif +typedef uint8_t byte_t; typedef int dap_spinlock_t; /** @@ -303,14 +302,8 @@ typedef struct dap_log_history_str_s { } dap_log_history_str_t; -#define DAP_INTERVAL_TIMERS_MAX 15 - +typedef void *dap_interval_timer_t; typedef void (*dap_timer_callback_t)(void *param); -typedef struct dap_timer_interface { - void *timer; - dap_timer_callback_t callback; - void *param; -} dap_timer_interface_t; #ifdef __cplusplus extern "C" { @@ -495,8 +488,10 @@ size_t dap_bin2hex(char *a_out, const void *a_in, size_t a_len); void dap_digit_from_string(const char *num_str, void *raw, size_t raw_len); void dap_digit_from_string2(const char *num_str, void *raw, size_t raw_len); -void *dap_interval_timer_create(unsigned int a_msec, dap_timer_callback_t a_callback, void *a_param); -int dap_interval_timer_delete(void *a_timer); +dap_interval_timer_t dap_interval_timer_create(unsigned int a_msec, dap_timer_callback_t a_callback, void *a_param); +void dap_interval_timer_delete(dap_interval_timer_t a_timer); +int dap_interval_timer_disable(dap_interval_timer_t a_timer); +void dap_interval_timer_init(); void dap_interval_timer_deinit(); static inline void * dap_mempcpy(void * a_dest,const void * a_src,size_t n) diff --git a/dap-sdk/core/include/dap_file_utils.h b/dap-sdk/core/include/dap_file_utils.h index 948e3e497baed8657d3aac671eb6682cbb168729..8d4769881e074fef0b4974dcbef419ef69d73f8b 100755 --- a/dap-sdk/core/include/dap_file_utils.h +++ b/dap-sdk/core/include/dap_file_utils.h @@ -90,6 +90,9 @@ bool dap_file_simple_test(const char * a_file_path); */ bool dap_file_test(const char * a_file_path); +// Move file +int dap_file_mv(const char* a_path_old, const char * a_path_new); + /** * Check the directory for exists * diff --git a/dap-sdk/core/include/dap_math_ops.h b/dap-sdk/core/include/dap_math_ops.h index 70a2de1ed95fbb6443d6e8f9f3982de424d6df19..759d007fb95499dabcb0f322d44dbedeeb15a5ed 100755 --- a/dap-sdk/core/include/dap_math_ops.h +++ b/dap-sdk/core/include/dap_math_ops.h @@ -208,7 +208,7 @@ static inline void LEFT_SHIFT_128(uint128_t a_128_bit,uint128_t* b_128_bit,int n a_128_bit.lo=0; LEFT_SHIFT_128(a_128_bit,b_128_bit,n-64); } - if (n == 0) { + else if (n == 0) { b_128_bit->hi=a_128_bit.hi; b_128_bit->lo=a_128_bit.lo; } @@ -234,7 +234,7 @@ static inline void RIGHT_SHIFT_128(uint128_t a_128_bit,uint128_t* b_128_bit,int a_128_bit.hi=0; RIGHT_SHIFT_128(a_128_bit,b_128_bit,n-64); } - if (n == 0) + else if (n == 0) { b_128_bit->hi=a_128_bit.hi; b_128_bit->lo=a_128_bit.lo; @@ -486,7 +486,8 @@ static inline int SUM_256_256(uint256_t a_256_bit,uint256_t b_256_bit,uint256_t* c_256_bit->hi = intermediate_value; overflow_flag=overflow_flag||overflow_flag_intermediate; #else - overflow_flag=SUM_128_128(a_256_bit.lo,b_256_bit.lo,&c_256_bit->lo); + uint256_t tmp = uint256_0; + overflow_flag=SUM_128_128(a_256_bit.lo,b_256_bit.lo,&tmp.lo); uint128_t carry_in_128; carry_in_128.hi=0; carry_in_128.lo=overflow_flag; @@ -494,7 +495,9 @@ static inline int SUM_256_256(uint256_t a_256_bit,uint256_t b_256_bit,uint256_t* overflow_flag=SUM_128_128(carry_in_128,a_256_bit.hi,&intermediate_value); //we store overflow_flag in case there is already overflow int overflow_flag_bis=0; - overflow_flag_bis=SUM_128_128(intermediate_value,b_256_bit.hi,&c_256_bit->hi); + overflow_flag_bis=SUM_128_128(intermediate_value,b_256_bit.hi,&tmp.hi); + c_256_bit->hi = tmp.hi; + c_256_bit->lo = tmp.lo; overflow_flag=overflow_flag||overflow_flag_bis; #endif return overflow_flag; @@ -615,8 +618,8 @@ static inline void MULT_128_256(uint128_t a_128_bit,uint128_t b_128_bit,uint256_ //product of .lo terms - stored in .lo field of c_256_bit MULT_64_128(a_128_bit.lo,b_128_bit.lo, &c_256_bit->lo); - uint128_t cross_product_one={.hi=0, .lo=0}; - uint128_t cross_product_two={.hi=0, .lo=0}; + uint128_t cross_product_one = GET_128_FROM_64(0); + uint128_t cross_product_two = GET_128_FROM_64(0); MULT_64_128(a_128_bit.hi, b_128_bit.lo, &cross_product_one); c_256_bit->lo.hi += cross_product_one.lo; if(c_256_bit->lo.hi < cross_product_one.lo) // if overflow @@ -652,7 +655,7 @@ static inline int MULT_128_128(uint128_t a_128_bit, uint128_t b_128_bit, uint128 overflow_flag=(a_128_bit>((uint128_t)-1)/b_128_bit); #else int equal_flag=0; - uint256_t full_product_256={.hi=uint128_0, .lo=uint128_0}; + uint256_t full_product_256 = GET_256_FROM_64(0); MULT_128_256(a_128_bit,b_128_bit,&full_product_256); *c_128_bit=full_product_256.lo; equal_flag=EQUAL_128(full_product_256.hi,uint128_0); diff --git a/dap-sdk/core/src/dap_common.c b/dap-sdk/core/src/dap_common.c index d644b1653f4e70d00e64df6a81ba7a26df14b0c1..4a703a57e5154be5d5e630375b0d5cf8ff8956e3 100755 --- a/dap-sdk/core/src/dap_common.c +++ b/dap-sdk/core/src/dap_common.c @@ -32,8 +32,8 @@ #include <stdint.h> #include <stdatomic.h> #include <ctype.h> - #include "utlist.h" +#include "uthash.h" //#include <errno.h> @@ -1101,48 +1101,68 @@ int exec_silent(const char * a_cmd) { #endif } -static int s_timers_count = 0; -static dap_timer_interface_t s_timers[DAP_INTERVAL_TIMERS_MAX]; -#ifdef _WIN32 -static CRITICAL_SECTION s_timers_lock; +typedef struct dap_timer_interface { +#ifdef DAP_OS_DARWIN + dispatch_source_t timer; #else -static pthread_mutex_t s_timers_lock; + void *timer; #endif - -void dap_interval_timer_deinit() + dap_timer_callback_t callback; + void *param; + UT_hash_handle hh; +} dap_timer_interface_t; +static dap_timer_interface_t *s_timers_map; +static pthread_rwlock_t s_timers_rwlock; + +void dap_interval_timer_init() { - for (int i = 0; i < s_timers_count; i++) { - dap_interval_timer_delete(s_timers[i].timer); - } + s_timers_map = NULL; + pthread_rwlock_init(&s_timers_rwlock, NULL); } -static int s_timer_find(void *a_timer) -{ - for (int i = 0; i < s_timers_count; i++) { - if (s_timers[i].timer == a_timer) { - return i; - } +void dap_interval_timer_deinit() { + pthread_rwlock_wrlock(&s_timers_rwlock); + dap_timer_interface_t *l_cur_timer = NULL, *l_tmp; + HASH_ITER(hh, s_timers_map, l_cur_timer, l_tmp) { + HASH_DEL(s_timers_map, l_cur_timer); + dap_interval_timer_disable(l_cur_timer->timer); + DAP_FREE(l_cur_timer); } - return -1; + pthread_rwlock_unlock(&s_timers_rwlock); + pthread_rwlock_destroy(&s_timers_rwlock); } -#ifdef _WIN32 +#ifdef DAP_OS_LINUX +static void s_posix_callback(union sigval a_arg) +{ + void *l_timer_ptr = a_arg.sival_ptr; +#elif defined (DAP_OS_WINDOWS) static void CALLBACK s_win_callback(PVOID a_arg, BOOLEAN a_always_true) { UNUSED(a_always_true); - s_timers[(size_t)a_arg].callback(s_timers[(size_t)a_arg].param); -} -#elif defined __MACH__ -static void s_bsd_callback(int a_arg) + void *l_timer_ptr = a_arg; +#elif defined (DAP_OS_DARWIN) +static void s_bsd_callback(void *a_arg) { - s_timers[a_arg].callback(s_timers[a_arg].param); -} + void *l_timer_ptr = &a_arg; #else -static void s_posix_callback(union sigval a_arg) -{ - s_timers[a_arg.sival_int].callback(s_timers[a_arg.sival_int].param); -} +#error "Timaer callback is undefined for your platform" #endif + if (!l_timer_ptr) { + log_it(L_ERROR, "Timer cb arg is NULL"); + return; + } + pthread_rwlock_rdlock(&s_timers_rwlock); + dap_timer_interface_t *l_timer = NULL; + HASH_FIND_PTR(s_timers_map, l_timer_ptr, l_timer); + pthread_rwlock_unlock(&s_timers_rwlock); + if (l_timer && l_timer->callback) { + //log_it(L_INFO, "Fire %p", l_timer_ptr); + l_timer->callback(l_timer->param); + } else { + log_it(L_WARNING, "Timer '%p' is not initialized", l_timer_ptr); + } +} /*! * \brief dap_interval_timer_create Create new timer object and set callback function to it @@ -1150,106 +1170,63 @@ static void s_posix_callback(union sigval a_arg) * \param a_callback Function to be called with timer period * \return pointer to timer object if success, otherwise return NULL */ -void *dap_interval_timer_create(unsigned int a_msec, dap_timer_callback_t a_callback, void *a_param) -{ - if (s_timers_count == DAP_INTERVAL_TIMERS_MAX) { - return NULL; - } +dap_interval_timer_t dap_interval_timer_create(unsigned int a_msec, dap_timer_callback_t a_callback, void *a_param) { + dap_timer_interface_t *l_timer_obj = DAP_NEW_Z(dap_timer_interface_t); + l_timer_obj->callback = a_callback; + l_timer_obj->param = a_param; #if (defined _WIN32) - if (s_timers_count == 0) { - InitializeCriticalSection(&s_timers_lock); - } - HANDLE l_timer; - if (!CreateTimerQueueTimer(&l_timer, NULL, (WAITORTIMERCALLBACK)s_win_callback, (PVOID)(size_t)s_timers_count, a_msec, a_msec, 0)) { + if (!CreateTimerQueueTimer(&l_timer_obj->timer , NULL, (WAITORTIMERCALLBACK)s_win_callback, &l_timer_obj->timer, a_msec, a_msec, 0)) { return NULL; } - EnterCriticalSection(&s_timers_lock); #elif (defined DAP_OS_DARWIN) - if (s_timers_count == 0) { - pthread_mutex_init(&s_timers_lock, NULL); - } - pthread_mutex_lock(&s_timers_lock); - dispatch_queue_t l_queue = dispatch_queue_create("tqueue", 0); - dispatch_source_t l_timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, l_queue); //todo: we should not use ^ like this, because this is clang-specific thing, but someone can use GCC on mac os - dispatch_source_set_event_handler(l_timer, ^(void){s_bsd_callback(s_timers_count);}); + l_timer_obj->timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, l_queue); + dispatch_source_set_event_handler((l_timer_obj->timer), ^(void){ s_bsd_callback((void*)(l_timer_obj->timer)); }); dispatch_time_t start = dispatch_time(DISPATCH_TIME_NOW, a_msec * 1000000); - dispatch_source_set_timer(l_timer, start, a_msec * 1000000, 0); - dispatch_resume(l_timer); + dispatch_source_set_timer(l_timer_obj->timer, start, a_msec * 1000000, 0); + dispatch_resume(l_timer_obj->timer); #else - if (s_timers_count == 0) { - pthread_mutex_init(&s_timers_lock, NULL); - } - timer_t l_timer; struct sigevent l_sig_event = { }; l_sig_event.sigev_notify = SIGEV_THREAD; - l_sig_event.sigev_value.sival_int = s_timers_count; + l_sig_event.sigev_value.sival_ptr = &l_timer_obj->timer; l_sig_event.sigev_notify_function = s_posix_callback; - if (timer_create(CLOCK_MONOTONIC, &l_sig_event, &l_timer)) { + if (timer_create(CLOCK_MONOTONIC, &l_sig_event, &(l_timer_obj->timer))) { return NULL; } struct itimerspec l_period = { }; l_period.it_interval.tv_sec = l_period.it_value.tv_sec = a_msec / 1000; l_period.it_interval.tv_nsec = l_period.it_value.tv_nsec = (a_msec % 1000) * 1000000; - timer_settime(l_timer, 0, &l_period, NULL); - pthread_mutex_lock(&s_timers_lock); + timer_settime(l_timer_obj->timer, 0, &l_period, NULL); #endif - s_timers[s_timers_count].timer = (void *)l_timer; - s_timers[s_timers_count].callback = a_callback; - s_timers[s_timers_count].param = a_param; - s_timers_count++; -#ifdef WIN32 - LeaveCriticalSection(&s_timers_lock); -#else - pthread_mutex_unlock(&s_timers_lock); -#endif - return (void *)l_timer; + pthread_rwlock_wrlock(&s_timers_rwlock); + HASH_ADD_PTR(s_timers_map, timer, l_timer_obj); + pthread_rwlock_unlock(&s_timers_rwlock); + log_it(L_DEBUG, "Interval timer %p created", &l_timer_obj->timer); + return (dap_interval_timer_t)l_timer_obj->timer; } -/*! - * \brief dap_interval_timer_delete Delete existed timer object and stop callback function calls - * \param a_timer A timer object created previously with dap_interval_timer_create - * \return 0 if success, -1 otherwise - */ -int dap_interval_timer_delete(void *a_timer) -{ - if (!s_timers_count) { - return -1; - } -#if (defined _WIN32) - EnterCriticalSection(&s_timers_lock); -#elif (defined DAP_OS_UNIX) - pthread_mutex_lock(&s_timers_lock); -#endif - int l_timer_idx = s_timer_find(a_timer); - if (l_timer_idx == -1) { - return -1; - } - for (int i = l_timer_idx; i < s_timers_count - 1; i++) { - s_timers[i] = s_timers[i + 1]; - } - s_timers_count--; +int dap_interval_timer_disable(dap_interval_timer_t a_timer) { #ifdef _WIN32 - LeaveCriticalSection(&s_timers_lock); - if (s_timers_count == 0) { - DeleteCriticalSection(&s_timers_lock); - } return !DeleteTimerQueueTimer(NULL, (HANDLE)a_timer, NULL); -#else - pthread_mutex_unlock(&s_timers_lock); - if (s_timers_count == 0) { - pthread_mutex_destroy(&s_timers_lock); - } -#ifdef DAP_OS_DARWIN - dispatch_source_cancel(a_timer); +#elif defined (DAP_OS_DARWIN) + dispatch_source_cancel((dispatch_source_t)a_timer); return 0; -#elif defined(DAP_OS_UNIX) - // POSIX timer delete +#else return timer_delete((timer_t)a_timer); -#endif // DAP_OS_UNIX +#endif +} -#endif // _WIN32 +void dap_interval_timer_delete(dap_interval_timer_t a_timer) { + pthread_rwlock_wrlock(&s_timers_rwlock); + dap_timer_interface_t *l_timer = NULL; + HASH_FIND_PTR(s_timers_map, &a_timer, l_timer); + if (l_timer) { + HASH_DEL(s_timers_map, l_timer); + dap_interval_timer_disable(l_timer->timer); + DAP_FREE(l_timer); + } + pthread_rwlock_unlock(&s_timers_rwlock); } char **dap_parse_items(const char *a_str, char a_delimiter, int *a_count, const int a_only_digit) diff --git a/dap-sdk/core/src/dap_file_utils.c b/dap-sdk/core/src/dap_file_utils.c index ebc11bd7294596cb56a0f1e49d167783e25cb09d..cf643a1c729748576a72d5c3f8688667f1012b1c 100755 --- a/dap-sdk/core/src/dap_file_utils.c +++ b/dap-sdk/core/src/dap_file_utils.c @@ -72,6 +72,17 @@ bool dap_valid_ascii_symbols(const char *a_string) return true; } +/** + * @brief dap_file_mv + * @param a_path_old + * @param a_path_new + * @return + */ +int dap_file_mv(const char* a_path_old, const char * a_path_new) +{ + return -1; +} + /** * Check the file for exists * diff --git a/dap-sdk/core/src/dap_string.c b/dap-sdk/core/src/dap_string.c index a49ac3a527a9600928a6ce8d2a34f22f895148e0..e36c722fdd600f4854435e572c69e13c01897587 100755 --- a/dap-sdk/core/src/dap_string.c +++ b/dap-sdk/core/src/dap_string.c @@ -156,13 +156,13 @@ char* dap_string_free(dap_string_t *a_string, bool a_free_segment) if(a_free_segment) { - DAP_DELETE(a_string->str); + DAP_DEL_Z(a_string->str); l_segment = NULL; } else l_segment = a_string->str; - DAP_DELETE(a_string); + DAP_DEL_Z(a_string); return l_segment; } diff --git a/dap-sdk/core/src/dap_time.c b/dap-sdk/core/src/dap_time.c index 46bf930e91b9a63e3c3ee4a2af7c832128e04c7d..d77e2f29d65da61879d5d6a08263e37abf238b40 100644 --- a/dap-sdk/core/src/dap_time.c +++ b/dap-sdk/core/src/dap_time.c @@ -64,7 +64,7 @@ long dap_gdb_time_to_sec(dap_nanotime_t a_time) dap_time_t dap_time_now(void) { time_t l_time = time(NULL); - return l_time; + return (dap_nanotime_t)l_time; } /** @@ -201,8 +201,8 @@ static void tmp_strptime(const char *buff, struct tm *tm) day = atoi(&tbuff[4]); tbuff[4] = '\0'; - if (day == 0) - day = 1; + if (day > 0) + day--; mon = atoi(&tbuff[2]); if (mon > 0) @@ -210,9 +210,7 @@ static void tmp_strptime(const char *buff, struct tm *tm) tbuff[2] = '\0'; year = atoi(tbuff); - if (year == 0) - year = 100; - else if (year < 69) + if (year < 69) year += 100; tm->tm_year = year; @@ -243,7 +241,7 @@ dap_time_t dap_time_from_str_simplified(const char *a_time_str) #else tmp_strptime(a_time_str, &l_tm); #endif - + l_tm.tm_sec++; time_t tmp = mktime(&l_tm); l_time = (tmp <= 0) ? 0 : tmp; return l_time; diff --git a/dap-sdk/crypto/include/dap_uuid.h b/dap-sdk/crypto/include/dap_uuid.h index 5e932f6d7f1bd30a0a9e8a59a8c01ff8d3c3e7e5..e6adab709ff4272a0990b96a3e329e0acc0db6b0 100644 --- a/dap-sdk/crypto/include/dap_uuid.h +++ b/dap-sdk/crypto/include/dap_uuid.h @@ -23,6 +23,7 @@ #pragma once #include "dap_math_ops.h" +#include <stdint.h> uint128_t dap_uuid_generate_uint128(); // Produce uint128 global unique id uint64_t dap_uuid_generate_uint64(); // Produce uint64 global unique id diff --git a/dap-sdk/crypto/src/dap_sign.c b/dap-sdk/crypto/src/dap_sign.c index 5a28e83eb5bf50159c1b8eb7069560faffabff74..f874e343e937eeef4a94eb082fc04ea9e807088c 100755 --- a/dap-sdk/crypto/src/dap_sign.c +++ b/dap-sdk/crypto/src/dap_sign.c @@ -394,18 +394,9 @@ bool dap_sign_match_pkey_signs(dap_sign_t *l_sign1, dap_sign_t *l_sign2) * @return true * @return false */ -bool dap_sign_verify_size(dap_sign_t *a_sign, size_t a_max_sign_size) -{ - if (a_sign->header.sign_size == 0 || a_sign->header.sign_pkey_size == 0 || a_sign->header.type.type == SIG_TYPE_NULL ) - return false; - - if (a_sign->header.sign_pkey_size > a_max_sign_size || a_sign->header.sign_size > a_max_sign_size) - return false; - - if (a_sign->header.sign_pkey_size + a_sign->header.sign_size + sizeof(*a_sign) > a_max_sign_size ) - return false; - - return true; +bool dap_sign_verify_size(dap_sign_t *a_sign, size_t a_max_sign_size) { + return (a_sign->header.sign_size) && (a_sign->header.sign_pkey_size) && (a_sign->header.type.type != SIG_TYPE_NULL) + && (a_sign->header.sign_size + a_sign->header.sign_pkey_size + sizeof(*a_sign) <= a_max_sign_size); } /** diff --git a/dap-sdk/io/dap_context.c b/dap-sdk/io/dap_context.c index 8e3625e5ca5a3e44223502ec6cfb965424c90db3..f7cd5f11ae9da2b273cd46b11f7e856dacbf0c66 100644 --- a/dap-sdk/io/dap_context.c +++ b/dap-sdk/io/dap_context.c @@ -686,7 +686,7 @@ static int s_thread_loop(dap_context_t * a_context) /* if we not reading data from socket, he triggered again */ #ifdef DAP_OS_WINDOWS l_bytes_read = dap_recvfrom(l_cur->socket, NULL, 0); -#else +#elif defined(DAP_OS_LINUX) uint64_t val; read( l_cur->fd, &val, 8); #endif diff --git a/dap-sdk/io/dap_events_socket.c b/dap-sdk/io/dap_events_socket.c index 18a9fad12b24e3e492c61593a7ff1b9a63a2357d..7bf7a0bb04cb19b4aff6cca5b8334058f2a9a91c 100644 --- a/dap-sdk/io/dap_events_socket.c +++ b/dap-sdk/io/dap_events_socket.c @@ -778,13 +778,7 @@ void dap_events_socket_event_proc_input_unsafe(dap_events_socket_t *a_esocket) log_it(L_ERROR, "Event socket %"DAP_FORMAT_SOCKET" accepted data but callback is NULL ", a_esocket->socket); } - -typedef struct dap_events_socket_buf_item -{ - dap_events_socket_t * es; - void *arg; -} dap_events_socket_buf_item_t; - +static pthread_rwlock_t *s_bufout_rwlock = NULL; /** * Waits on the socket * return 0: timeout, 1: may send data, -1 error @@ -833,29 +827,35 @@ static int wait_send_socket(SOCKET a_sockfd, long timeout_ms) */ static void *dap_events_socket_buf_thread(void *arg) { - dap_events_socket_buf_item_t *l_item = (dap_events_socket_buf_item_t *)arg; - if (!l_item) + dap_events_socket_t *l_es = (dap_events_socket_t *)arg; + if (!l_es) pthread_exit(0); int l_res = 0; int l_count = 0; SOCKET l_sock = INVALID_SOCKET; - while (l_res < 1 && l_count++ < 3) { + bool l_lifecycle = true; + while (l_lifecycle) { + while (l_res < 1 && l_count++ < 3) { #if defined(DAP_EVENTS_CAPS_QUEUE_PIPE2) - l_sock = l_item->es->fd2; + l_sock = l_item->es->fd2; #elif defined(DAP_EVENTS_CAPS_QUEUE_MQUEUE) - l_sock = l_item->es->mqd; + l_sock = l_item->es->mqd; #endif - // wait max 5 min - l_res = wait_send_socket(l_sock, 300000); - if (l_res == 0) { - dap_events_socket_queue_ptr_send(l_item->es, l_item->arg); - break; + // wait max 5 min + l_res = wait_send_socket(l_sock, 300000); + if (l_res == 0) { + pthread_rwlock_wrlock(s_bufout_rwlock); + void *l_ptr = *((void **)l_es->buf_out + --l_es->buf_out_size); + if (!l_es->buf_out_size) + l_lifecycle = false; + pthread_rwlock_unlock(s_bufout_rwlock); + dap_events_socket_queue_ptr_send(l_es, l_ptr); + break; + } } + if (l_res != 0) + log_it(L_WARNING, "Lost data bulk in events socket buf thread"); } - if (l_res != 0) - log_it(L_WARNING, "Lost data bulk in events socket buf thread"); - - DAP_DELETE(l_item); pthread_exit(0); return NULL; } @@ -865,29 +865,35 @@ static void add_ptr_to_buf(dap_events_socket_t * a_es, void* a_arg) static atomic_uint_fast64_t l_thd_count; int l_rc; pthread_t l_thread; -dap_events_socket_buf_item_t *l_item; +const size_t l_basic_buf_size = DAP_QUEUE_MAX_MSGS * sizeof(void *); atomic_fetch_add(&l_thd_count, 1); /* Count an every call of this routine */ - if ( !(l_item = DAP_NEW(dap_events_socket_buf_item_t)) ) /* Allocate new item - argument for new thread */ - { - log_it (L_ERROR, "[#%"DAP_UINT64_FORMAT_U"] No memory for new item, errno=%d, drop: a_es: %p, a_arg: %p", - atomic_load(&l_thd_count), errno, a_es, a_arg); - return; + if (!s_bufout_rwlock) { + s_bufout_rwlock = DAP_NEW(pthread_rwlock_t); + pthread_rwlock_init(s_bufout_rwlock, NULL); + } + pthread_rwlock_wrlock(s_bufout_rwlock); + if (!a_es->buf_out) { + a_es->buf_out = DAP_NEW_SIZE(byte_t, l_basic_buf_size); + a_es->buf_out_size_max = l_basic_buf_size; } - l_item->es = a_es; - l_item->arg = a_arg; - - if ( (l_rc = pthread_create(&l_thread, &s_attr_detached /* @RRL: #6157 */, dap_events_socket_buf_thread, l_item)) ) - { + if (!a_es->buf_out_size) { + if ((l_rc = pthread_create(&l_thread, &s_attr_detached /* @RRL: #6157 */, dap_events_socket_buf_thread, a_es))) { log_it(L_ERROR, "[#%"DAP_UINT64_FORMAT_U"] Cannot start thread, drop a_es: %p, a_arg: %p, rc: %d", atomic_load(&l_thd_count), a_es, a_arg, l_rc); return; } - debug_if(g_debug_reactor, L_DEBUG, "[#%"DAP_UINT64_FORMAT_U"] Created thread %"DAP_UINT64_FORMAT_x", a_es: %p, a_arg: %p", atomic_load(&l_thd_count), l_thread, a_es, a_arg); + } + *((void **)a_es->buf_out + a_es->buf_out_size++) = a_arg; + if (a_es->buf_out_size == a_es->buf_out_size_max) { + a_es->buf_out = DAP_REALLOC(a_es->buf_out, a_es->buf_out_size + l_basic_buf_size); + a_es->buf_out_size_max += l_basic_buf_size; + } + pthread_rwlock_unlock(s_bufout_rwlock); } #endif @@ -989,9 +995,7 @@ int dap_events_socket_queue_ptr_send( dap_events_socket_t *a_es, void *a_arg) case EINTR: case EWOULDBLOCK: log_it(L_ERROR, "Can't send ptr to queue (err %d), will be resent again in a while...", l_errno); - struct mq_attr l_attr = { 0 }; - mq_getattr(a_es->mqd, &l_attr); - log_it(L_ERROR, "Number of pending messages: %ld", l_attr.mq_curmsgs); + log_it(L_ERROR, "Number of pending messages: %ld", a_es->buf_out_size); add_ptr_to_buf(a_es, a_arg); return l_errno; default: { diff --git a/dap-sdk/io/dap_net.c b/dap-sdk/io/dap_net.c index c4b9fb3b9e60a4d902f320c474ddc5868bcf86de..be9da69cf36c63f0fd98a29eb9c12fe7200da50f 100644 --- a/dap-sdk/io/dap_net.c +++ b/dap-sdk/io/dap_net.c @@ -46,12 +46,13 @@ int dap_net_resolve_host(const char *a_host, int ai_family, struct sockaddr *a_a void *l_cur_addr = NULL; memset(&l_hints, 0, sizeof(l_hints)); - l_hints.ai_family = PF_UNSPEC; + l_hints.ai_family = ai_family == AF_INET ? PF_INET : PF_INET6; l_hints.ai_socktype = SOCK_STREAM; - l_hints.ai_flags |= AI_CANONNAME; + l_hints.ai_flags = AI_CANONNAME; - if ( getaddrinfo(a_host, NULL, &l_hints, &l_res) ) - return -2; + int l_res_code = getaddrinfo(a_host, NULL, &l_hints, &l_res); + if (l_res_code) + return l_res_code; while(l_res) { diff --git a/dap-sdk/io/dap_timerfd.c b/dap-sdk/io/dap_timerfd.c index a8c494426ca4d0db361dacbbfedb5875198490d5..d72233f2a700d3c7eca1d17c6857ffa2543f11cb 100644 --- a/dap-sdk/io/dap_timerfd.c +++ b/dap-sdk/io/dap_timerfd.c @@ -278,6 +278,8 @@ static inline void s_timerfd_reset(dap_timerfd_t *a_timerfd, dap_events_socket_t static void s_es_callback_timer(struct dap_events_socket *a_event_sock) { dap_timerfd_t *l_timer_fd = a_event_sock->_inheritor; + if(!l_timer_fd) + return; // run user's callback if(l_timer_fd && l_timer_fd->callback && l_timer_fd->callback(l_timer_fd->callback_arg)) { s_timerfd_reset(l_timer_fd, a_event_sock); diff --git a/dap-sdk/net/client/dap_client.c b/dap-sdk/net/client/dap_client.c index 879e7f83632c93992fa673e8b4f47c26b73b28b8..c651688184cd5cdad02f2c64aa95e7eaf3b36bf8 100644 --- a/dap-sdk/net/client/dap_client.c +++ b/dap-sdk/net/client/dap_client.c @@ -250,13 +250,14 @@ void dap_client_delete_unsafe(dap_client_t * a_client) static void s_stage_done_delete(dap_client_t * a_client, void * a_arg) { (void) a_arg; - pthread_mutex_destroy(&a_client->mutex); + if (a_client) + pthread_mutex_destroy(&a_client->mutex); } struct go_stage_arg{ bool flag_delete_after;// Delete after stage achievement - dap_client_pvt_t *client_pvt; + uint64_t client_pvt_uuid; dap_client_stage_t stage_target; dap_client_callback_t stage_end_callback; }; @@ -270,12 +271,24 @@ static void s_go_stage_on_client_worker_unsafe(dap_worker_t * a_worker,void * a_ { (void) a_worker; assert(a_arg); - dap_client_stage_t l_stage_target = ((struct go_stage_arg*) a_arg)->stage_target; - dap_client_callback_t l_stage_end_callback= ((struct go_stage_arg*) a_arg)->stage_end_callback; - dap_client_pvt_t * l_client_pvt = ((struct go_stage_arg*) a_arg)->client_pvt; + struct go_stage_arg* l_args = (struct go_stage_arg*) a_arg; + dap_client_stage_t l_stage_target = l_args->stage_target; + dap_client_callback_t l_stage_end_callback= l_args->stage_end_callback; + + dap_client_pvt_t * l_client_pvt = dap_client_pvt_find( l_args->client_pvt_uuid); + // Check if its not present now and exit if its already deleted + if ( !l_client_pvt){ + log_it (L_NOTICE, "Client is not present in global table, exit s_go_stage_on_client_worker_unsafe()"); + goto lb_exit; + } + // Wrong worker + if( l_client_pvt->worker != a_worker) { + log_it (L_NOTICE, "Wrong worker for client thats differs from what is present in client_pvt, exit s_go_stage_on_client_worker_unsafe()"); + goto lb_exit; + } + dap_client_t *l_client = l_client_pvt->client; - bool l_flag_delete_after = ((struct go_stage_arg *) a_arg)->flag_delete_after ;// Delete after stage achievement - DAP_DELETE(a_arg); + bool l_flag_delete_after = l_args->flag_delete_after ;// Delete after stage achievement l_client_pvt->is_to_delete = l_flag_delete_after; if (!l_client || l_client->_internal != l_client_pvt) { @@ -284,7 +297,7 @@ static void s_go_stage_on_client_worker_unsafe(dap_worker_t * a_worker,void * a_ dap_client_pvt_delete_unsafe(l_client_pvt); } else l_client_pvt->is_to_delete = true; - return; + goto lb_exit; } dap_client_stage_t l_cur_stage = l_client_pvt->stage; @@ -294,12 +307,12 @@ static void s_go_stage_on_client_worker_unsafe(dap_worker_t * a_worker,void * a_ case STAGE_STATUS_DONE: log_it(L_DEBUG, "Already have target state %s", dap_client_stage_str(l_stage_target)); if (l_stage_end_callback) { - l_stage_end_callback(l_client_pvt->client, NULL); + l_stage_end_callback(l_client, NULL); } break; case STAGE_STATUS_ERROR: log_it(L_DEBUG, "Already moving target state %s, but status is error (%s)", dap_client_stage_str(l_stage_target), - dap_client_get_error_str( l_client_pvt->client) ); + dap_client_get_error_str(l_client)); break; case STAGE_STATUS_IN_PROGRESS: log_it(L_DEBUG, "Already moving target state %s", dap_client_stage_str(l_stage_target)); @@ -309,10 +322,11 @@ static void s_go_stage_on_client_worker_unsafe(dap_worker_t * a_worker,void * a_ dap_client_stage_status_str( l_cur_stage_status)); } l_client_pvt->refs_count--; - dap_client_delete_unsafe(l_client_pvt->client); - return; + dap_client_delete_unsafe(l_client); + goto lb_exit; } - log_it(L_DEBUG, "Start transitions chain for client %p -> %p from %s to %s", l_client_pvt, l_client_pvt->client, dap_client_stage_str(l_cur_stage ) , dap_client_stage_str(l_stage_target)); + log_it(L_DEBUG, "Start transitions chain for client %p -> %p from %s to %s", l_client_pvt, l_client, + dap_client_stage_str(l_cur_stage) , dap_client_stage_str(l_stage_target)); l_client_pvt->stage_target = l_stage_target; l_client_pvt->stage_target_done_callback = l_stage_end_callback; if (l_stage_target < l_cur_stage) { @@ -342,7 +356,8 @@ static void s_go_stage_on_client_worker_unsafe(dap_worker_t * a_worker,void * a_ l_client_pvt->refs_count--; if ( l_client_pvt->is_to_delete ) dap_client_delete_unsafe(l_client); - +lb_exit: + DAP_DELETE(l_args); } /** * @brief dap_client_go_stage @@ -366,7 +381,7 @@ void dap_client_go_stage(dap_client_t * a_client, dap_client_stage_t a_stage_tar struct go_stage_arg *l_stage_arg = DAP_NEW_Z(struct go_stage_arg); if (! l_stage_arg) return; l_stage_arg->stage_end_callback = a_stage_end_callback; l_stage_arg->stage_target = a_stage_target; - l_stage_arg->client_pvt = l_client_pvt; + l_stage_arg->client_pvt_uuid = a_client->pvt_uuid; dap_worker_exec_callback_on(l_client_pvt->worker, s_go_stage_on_client_worker_unsafe, l_stage_arg); } @@ -383,7 +398,7 @@ void dap_client_delete_mt(dap_client_t * a_client) struct go_stage_arg *l_stage_arg = DAP_NEW(struct go_stage_arg); if (! l_stage_arg) return; l_stage_arg->stage_end_callback = s_stage_done_delete ; l_stage_arg->stage_target = STAGE_BEGIN ; - l_stage_arg->client_pvt = l_client_pvt; + l_stage_arg->client_pvt_uuid = a_client->pvt_uuid; l_stage_arg->flag_delete_after = true; dap_worker_exec_callback_on(l_client_pvt->worker, s_go_stage_on_client_worker_unsafe, l_stage_arg); } diff --git a/dap-sdk/net/client/dap_client_pvt_hh.c b/dap-sdk/net/client/dap_client_pvt_hh.c index 22c0e6869f88fd78f0544a938c755f485cbd0261..1ef4bc63b475451022f7b6da7d1fac9f5cd3a607 100644 --- a/dap-sdk/net/client/dap_client_pvt_hh.c +++ b/dap-sdk/net/client/dap_client_pvt_hh.c @@ -36,7 +36,7 @@ typedef struct dap_client_pvt_hh { // List of active connections static dap_client_pvt_hh_t *s_client_pvt_list = NULL; // for separate access to s_conn_list -static pthread_mutex_t s_client_pvt_list_mutex = PTHREAD_MUTEX_INITIALIZER; +static pthread_rwlock_t s_client_pvt_list_rwlock = PTHREAD_RWLOCK_INITIALIZER; /** @@ -47,10 +47,10 @@ static pthread_mutex_t s_client_pvt_list_mutex = PTHREAD_MUTEX_INITIALIZER; dap_client_pvt_t *dap_client_pvt_find(uint64_t a_client_pvt_uuid) { bool l_ret = false; - pthread_mutex_lock(&s_client_pvt_list_mutex); + pthread_rwlock_rdlock(&s_client_pvt_list_rwlock); dap_client_pvt_hh_t *l_cur_item = NULL; HASH_FIND_PTR(s_client_pvt_list, &a_client_pvt_uuid, l_cur_item); - pthread_mutex_unlock(&s_client_pvt_list_mutex); + pthread_rwlock_unlock(&s_client_pvt_list_rwlock); return l_cur_item? l_cur_item->client_pvt : NULL; } @@ -63,7 +63,7 @@ int dap_client_pvt_hh_add_unsafe(dap_client_pvt_t* a_client_pvt) { int l_ret = 0; assert(a_client_pvt); - pthread_mutex_lock(&s_client_pvt_list_mutex); + pthread_rwlock_wrlock(&s_client_pvt_list_rwlock); dap_client_pvt_hh_t *l_cur_item = NULL; HASH_FIND_PTR(s_client_pvt_list, &a_client_pvt->uuid, l_cur_item); if(l_cur_item == NULL) { @@ -77,7 +77,7 @@ int dap_client_pvt_hh_add_unsafe(dap_client_pvt_t* a_client_pvt) else l_ret = -2; //connect_list = g_list_append(connect_list, client); - pthread_mutex_unlock(&s_client_pvt_list_mutex); + pthread_rwlock_unlock(&s_client_pvt_list_rwlock); return l_ret; } @@ -90,7 +90,7 @@ int dap_client_pvt_hh_del_unsafe(dap_client_pvt_t *a_client_pvt) { int ret = -1; assert(a_client_pvt); - pthread_mutex_lock(&s_client_pvt_list_mutex); + pthread_rwlock_wrlock(&s_client_pvt_list_rwlock); dap_client_pvt_hh_t *l_cur_item = NULL; HASH_FIND_PTR(s_client_pvt_list, &a_client_pvt->uuid, l_cur_item); if(l_cur_item != NULL) { @@ -102,6 +102,6 @@ int dap_client_pvt_hh_del_unsafe(dap_client_pvt_t *a_client_pvt) else { ret = -2; } - pthread_mutex_unlock(&s_client_pvt_list_mutex); + pthread_rwlock_unlock(&s_client_pvt_list_rwlock); return ret; } diff --git a/dap-sdk/net/client/include/dap_client.h b/dap-sdk/net/client/include/dap_client.h index 9ac1b35a5eac880ce359e4ffcdbfc969731fa7fd..923492769a8028d922fd818ad2d6e8428e300d58 100644 --- a/dap-sdk/net/client/include/dap_client.h +++ b/dap-sdk/net/client/include/dap_client.h @@ -78,6 +78,7 @@ typedef struct dap_client{ void * _internal; void * _inheritor; uint64_t pvt_uuid; + dap_events_socket_uuid_t es_uuid; } dap_client_t; typedef void (*dap_client_callback_t) (dap_client_t *, void*); diff --git a/dap-sdk/net/server/enc_server/dap_enc_http.c b/dap-sdk/net/server/enc_server/dap_enc_http.c index df5a6b4ac2f65cde635648acf9a2f95b9ebd43b3..4b127cab38ed3434536b1ee503efe5387952d8dd 100644 --- a/dap-sdk/net/server/enc_server/dap_enc_http.c +++ b/dap-sdk/net/server/enc_server/dap_enc_http.c @@ -107,25 +107,20 @@ void enc_http_proc(struct dap_http_simple *cl_st, void * arg) dap_enc_get_type_name(l_pkey_exchange_type)); uint8_t alice_msg[cl_st->request_size]; size_t l_decode_len = dap_enc_base64_decode(cl_st->request, cl_st->request_size, alice_msg, DAP_ENC_DATA_TYPE_B64); - dap_chain_hash_fast_t l_sign_hash = {}; - if (l_decode_len < l_pkey_exchange_size) { - log_it(L_WARNING, "Wrong http_enc request. Key not equal pkey exchange size %zd", l_pkey_exchange_size); - *return_code = Http_Status_BadRequest; - return; - } else if (l_decode_len > l_pkey_exchange_size+ sizeof (dap_sign_hdr_t)) { + dap_chain_hash_fast_t l_sign_hash = { }; + if (l_decode_len > l_pkey_exchange_size + sizeof(dap_sign_hdr_t)) { + /* Message contains pubkey and serialized sign */ dap_sign_t *l_sign = (dap_sign_t *)&alice_msg[l_pkey_exchange_size]; - if(!dap_sign_verify_size(l_sign, l_decode_len - l_pkey_exchange_size)) { - log_it(L_WARNING,"Wrong signature size %u (decoded length %zu)",l_sign->header.sign_size, l_decode_len); - *return_code = Http_Status_BadRequest; - return; - } - if (dap_sign_verify(l_sign, alice_msg, l_pkey_exchange_size) != 1) { + size_t l_sign_size = l_decode_len - l_pkey_exchange_size; + int l_verify_ret = dap_sign_verify_all(l_sign, l_sign_size, alice_msg, l_pkey_exchange_size); + if (l_verify_ret) { + log_it(L_ERROR, "Can't authorize, sign verification didn't pass (err %d)", l_verify_ret); *return_code = Http_Status_Unauthorized; return; } - dap_sign_get_pkey_hash(l_sign, &l_sign_hash); - }else if( l_decode_len != l_pkey_exchange_size){ - log_it(L_WARNING, "Wrong http_enc request. Data after pkey exchange is lesser or equal then signature's header"); + } else if (l_decode_len != l_pkey_exchange_size) { + /* No sign inside */ + log_it(L_WARNING, "Wrong message size, without a valid sign must be = %zu", l_pkey_exchange_size); *return_code = Http_Status_BadRequest; return; } @@ -172,6 +167,7 @@ void enc_http_proc(struct dap_http_simple *cl_st, void * arg) } else{ log_it(L_ERROR,"Wrong path '%s' in the request to enc_http module",cl_st->http_client->url_path); *return_code = Http_Status_NotFound; + return; } } diff --git a/dap-sdk/net/server/http_server/dap_http_simple.c b/dap-sdk/net/server/http_server/dap_http_simple.c index 657fabbac80ea115c0a634b650161c5ae0f8b7ad..cd7f86e8f2745d4430996ed1b2b6cb80dcd7f228 100644 --- a/dap-sdk/net/server/http_server/dap_http_simple.c +++ b/dap-sdk/net/server/http_server/dap_http_simple.c @@ -224,10 +224,17 @@ static void s_esocket_worker_write_callback(dap_worker_t *a_worker, void *a_arg) dap_events_socket_t *l_es = dap_context_find(a_worker->context, l_http_simple->esocket_uuid); if (!l_es) { debug_if(g_debug_reactor, L_INFO, "Esocket 0x%"DAP_UINT64_FORMAT_x" is already deleted", l_http_simple->esocket_uuid); + dap_http_client_t *l_http_client = l_http_simple->http_client; + if (l_http_client) { + while (l_http_client->in_headers) + dap_http_header_remove(&l_http_client->in_headers, l_http_client->in_headers); + while (l_http_client->out_headers) + dap_http_header_remove(&l_http_client->out_headers, l_http_client->out_headers); + DAP_DELETE(l_http_client); + } DAP_DEL_Z(l_http_simple->request); DAP_DEL_Z(l_http_simple->reply); - DAP_DEL_Z(l_http_simple->http_client); - DAP_DELETE(a_arg); // http_simple itself + DAP_DELETE(l_http_simple); return; } l_es->_inheritor = l_http_simple->http_client; // Back to the owner @@ -345,8 +352,10 @@ static void s_http_client_delete( dap_http_client_t *a_http_client, void *arg ) { dap_http_simple_t * l_http_simple = DAP_HTTP_SIMPLE(a_http_client); - if (l_http_simple) + if (l_http_simple) { + DAP_DEL_Z(l_http_simple->request); DAP_DEL_Z(l_http_simple->reply_byte); + } } static void s_http_client_headers_read( dap_http_client_t *a_http_client, void *a_arg ) diff --git a/dap-sdk/net/server/http_server/http_client/dap_http_client.c b/dap-sdk/net/server/http_server/http_client/dap_http_client.c index 351ac29ba1af41d778bac5e0d590bb5711d046dd..60cc038a3385f6e382b80bbe85b6cd687843ac8b 100644 --- a/dap-sdk/net/server/http_server/http_client/dap_http_client.c +++ b/dap-sdk/net/server/http_server/http_client/dap_http_client.c @@ -124,7 +124,7 @@ void dap_http_client_delete( dap_events_socket_t * a_esocket, void *a_arg ) l_http_client->proc->delete_callback( l_http_client, NULL ); } } - DAP_DEL_Z(l_http_client->_inheritor) + DAP_DEL_Z(l_http_client->_inheritor); } diff --git a/dap-sdk/net/stream/ch/dap_stream_ch.c b/dap-sdk/net/stream/ch/dap_stream_ch.c index d6873a645720a02ed65830ce2d468acc143c69c6..b4f3b4a970889f6465f62370f793ae6d263d61a1 100644 --- a/dap-sdk/net/stream/ch/dap_stream_ch.c +++ b/dap-sdk/net/stream/ch/dap_stream_ch.c @@ -150,7 +150,7 @@ void dap_stream_ch_delete(dap_stream_ch_t *a_ch) */ dap_stream_ch_t * dap_stream_ch_find_by_uuid_unsafe(dap_stream_worker_t * a_worker, dap_stream_ch_uuid_t a_ch_uuid) { -dap_stream_ch_t *l_ch = NULL; + dap_stream_ch_t *l_ch = NULL; if( a_worker == NULL ){ log_it(L_WARNING,"Attempt to search for uuid 0x%016"DAP_UINT64_FORMAT_U" in NULL worker", a_ch_uuid);