diff --git a/dap-sdk/core/include/dap_common.h b/dap-sdk/core/include/dap_common.h index aadab746d6b08b6666e4fd9442b94ddbe735ab62..2d1f1dce2e41db9610efee106b3f670b065c57e8 100755 --- a/dap-sdk/core/include/dap_common.h +++ b/dap-sdk/core/include/dap_common.h @@ -33,6 +33,7 @@ #include <stdint.h> #include <stdlib.h> #include <stdio.h> +#include <time.h> #ifndef __cplusplus # include <stdatomic.h> @@ -50,6 +51,7 @@ #define pipe(pfds) _pipe(pfds, 4096, _O_BINARY) #define strerror_r(arg1, arg2, arg3) strerror_s(arg2, arg3, arg1) #define ctime_r(arg1, arg2) ctime_s(arg2, sizeof(arg2), arg1) +#define asctime_r(arg1, arg2) asctime_s(arg2, sizeof(arg2), arg1) #endif #ifdef __MACH__ #include <dispatch/dispatch.h> @@ -453,6 +455,14 @@ void dap_lendian_put64(uint8_t *a_buf, uint64_t a_val); #define DAP_USEC_PER_SEC 1000000 void dap_usleep(time_t a_microseconds); +/** + * @brief dap_ctime_r This function does the same as ctime_r, but if it returns (null), a line break is added. + * @param a_time + * @param a_buf The minimum buffer size is 26 elements. + * @return + */ +char* dap_ctime_r(time_t *a_time, char* a_buf); + #ifdef __MINGW32__ diff --git a/dap-sdk/core/src/dap_common.c b/dap-sdk/core/src/dap_common.c index 928d1220399f477b8b1cb83ea535ad6b4429592d..d841a31371cbe6d36057afa9f1ecf199850149e7 100755 --- a/dap-sdk/core/src/dap_common.c +++ b/dap-sdk/core/src/dap_common.c @@ -1066,3 +1066,13 @@ void dap_usleep(time_t a_microseconds) #endif } + +char* dap_ctime_r(time_t *a_time, char* a_buf){ + struct tm *l_time = localtime(a_time); + char *l_str_time = asctime_r(l_time, a_buf); + if (l_str_time) + return l_str_time; + else + return "(null)\n"; +// localtime_r() +} diff --git a/modules/chain/dap_chain_ledger.c b/modules/chain/dap_chain_ledger.c index e500a93195eac8da35c423066ec86551452f2117..829f72ad5cf39bd039cc63a1667dce3e356211b5 100644 --- a/modules/chain/dap_chain_ledger.c +++ b/modules/chain/dap_chain_ledger.c @@ -1787,8 +1787,11 @@ int dap_chain_ledger_tx_cache_check(dap_ledger_t *a_ledger, dap_chain_datum_tx_t break; } } + pthread_rwlock_unlock(&l_ledger_priv->tokens_rwlock); } + + if ( l_list_out ) dap_list_free(l_list_out); diff --git a/modules/net/dap_chain_net.c b/modules/net/dap_chain_net.c index 40c731ae3d194ab852077f5268b215977175b400..e78f97b6724cc6a07387b26546e10f7b6d6a422e 100644 --- a/modules/net/dap_chain_net.c +++ b/modules/net/dap_chain_net.c @@ -1652,7 +1652,7 @@ int s_net_load(const char * a_net_name, uint16_t a_acl_idx) PVT(l_net)->node_info = dap_chain_node_info_read (l_net, l_node_addr); if ( !PVT(l_net)->node_info ) { // If not present - create it PVT(l_net)->node_info = DAP_NEW_Z(dap_chain_node_info_t); - memcpy(&PVT(l_net)->node_info->hdr.address, &l_node_addr,sizeof (*l_node_addr)); + memcpy(&PVT(l_net)->node_info->hdr.address, l_node_addr,sizeof (*l_node_addr)); dap_chain_node_info_save(l_net,PVT(l_net)->node_info); } log_it(L_NOTICE,"GDB Info: node_addr: " NODE_ADDR_FP_STR" links: %u cell_id: 0x%016X ",