Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • cellframe/cellframe-sdk
  • MIKA83/cellframe-sdk
2 results
Show changes
Commits on Source (1)
Showing
with 69 additions and 36 deletions
...@@ -29,7 +29,8 @@ CDBLOCK *cdb_lock_new(int ltype) ...@@ -29,7 +29,8 @@ CDBLOCK *cdb_lock_new(int ltype)
lock = (CDBLOCK *)malloc(sizeof(CDBLOCK) + sizeof(pthread_mutex_t)); lock = (CDBLOCK *)malloc(sizeof(CDBLOCK) + sizeof(pthread_mutex_t));
pthread_mutex_init((pthread_mutex_t*)&lock->lock, NULL); pthread_mutex_init((pthread_mutex_t*)&lock->lock, NULL);
} }
lock->ltype = ltype; if( lock)
lock->ltype = ltype;
return lock; return lock;
} }
......
...@@ -48,9 +48,9 @@ ...@@ -48,9 +48,9 @@
/* if page cache size exceeds the limit */ /* if page cache size exceeds the limit */
#define PCOVERFLOW(db) ((db)->dpcache && (db)->dpcache->size + (db)->pcache->size > (db)->pclimit) #define PCOVERFLOW(db) ( (db) && (db)->dpcache && (db)->pcache && (db)->dpcache->size + (db)->pcache->size > (db)->pclimit)
/* if record cache size exceeds the limit */ /* if record cache size exceeds the limit */
#define RCOVERFLOW(db) ((db)->rcache && (db)->rcache->size > (db)->rclimit) #define RCOVERFLOW(db) ((db) && (db)->rcache && (db)->rcache->size > (db)->rclimit)
/* timeout for a dirty index page stays since last modify */ /* timeout for a dirty index page stays since last modify */
#define DPAGETIMEOUT 40 #define DPAGETIMEOUT 40
......
...@@ -2,7 +2,7 @@ project(cellframe-sdk C) ...@@ -2,7 +2,7 @@ project(cellframe-sdk C)
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 2.8)
set(CMAKE_C_STANDARD 11) set(CMAKE_C_STANDARD 11)
set(CELLFRAME_SDK_NATIVE_VERSION "2.6-62") set(CELLFRAME_SDK_NATIVE_VERSION "2.6-63")
add_definitions ("-DCELLFRAME_SDK_VERSION=\"${CELLFRAME_SDK_NATIVE_VERSION}\"") add_definitions ("-DCELLFRAME_SDK_VERSION=\"${CELLFRAME_SDK_NATIVE_VERSION}\"")
set(DAPSDK_MODULES "") set(DAPSDK_MODULES "")
......
...@@ -138,13 +138,15 @@ static dap_binary_tree_t *s_tree_delete(dap_binary_tree_t *a_elm, dap_binary_tre ...@@ -138,13 +138,15 @@ static dap_binary_tree_t *s_tree_delete(dap_binary_tree_t *a_elm, dap_binary_tre
a_elm->data = l_tmp->data; a_elm->data = l_tmp->data;
a_elm->right = s_tree_delete(a_elm->right, a_elm->key); a_elm->right = s_tree_delete(a_elm->right, a_elm->key);
} else if (a_elm->left) { } else if (a_elm->left) {
dap_binary_tree_t * l_elm_old = a_elm;
DAP_DELETE(a_elm->data); DAP_DELETE(a_elm->data);
DAP_DELETE(a_elm); DAP_DELETE(a_elm);
a_elm = a_elm->left; a_elm = l_elm_old->left;
} else if (a_elm->right) { } else if (a_elm->right) {
dap_binary_tree_t * l_elm_old = a_elm;
DAP_DELETE(a_elm->data); DAP_DELETE(a_elm->data);
DAP_DELETE(a_elm); DAP_DELETE(a_elm);
a_elm = a_elm->right; a_elm = l_elm_old->right;
} else { } else {
DAP_DELETE(a_elm->data); DAP_DELETE(a_elm->data);
DAP_DELETE(a_elm); DAP_DELETE(a_elm);
......
...@@ -349,8 +349,14 @@ dap_list_t *dap_list_remove(dap_list_t *list, const void * data) ...@@ -349,8 +349,14 @@ dap_list_t *dap_list_remove(dap_list_t *list, const void * data)
tmp = tmp->next; tmp = tmp->next;
else else
{ {
list = _dap_list_remove_link(list, tmp); if (list == tmp){
dap_list_free1(tmp); _dap_list_remove_link(list, tmp);
list = NULL;
tmp = NULL;
}else {
list = _dap_list_remove_link(list, tmp);
dap_list_free1(tmp);
}
break; break;
} }
} }
...@@ -388,6 +394,8 @@ dap_list_t *dap_list_remove_all(dap_list_t *list, const void * data) ...@@ -388,6 +394,8 @@ dap_list_t *dap_list_remove_all(dap_list_t *list, const void * data)
if(next) if(next)
next->prev = tmp->prev; next->prev = tmp->prev;
if (tmp == list)
list = NULL;
dap_list_free1(tmp); dap_list_free1(tmp);
tmp = next; tmp = next;
} }
......
...@@ -263,13 +263,13 @@ int dap_events_start( dap_events_t *a_events ) ...@@ -263,13 +263,13 @@ int dap_events_start( dap_events_t *a_events )
pthread_mutex_lock(&l_worker->started_mutex); pthread_mutex_lock(&l_worker->started_mutex);
struct timespec l_timeout; struct timespec l_timeout;
clock_gettime(CLOCK_REALTIME, &l_timeout); clock_gettime(CLOCK_REALTIME, &l_timeout);
l_timeout.tv_sec+=5; l_timeout.tv_sec+=15;
pthread_create( &s_threads[i].tid, NULL, dap_worker_thread, l_worker ); pthread_create( &s_threads[i].tid, NULL, dap_worker_thread, l_worker );
int l_ret; int l_ret;
l_ret=pthread_cond_timedwait(&l_worker->started_cond, &l_worker->started_mutex, &l_timeout); l_ret=pthread_cond_timedwait(&l_worker->started_cond, &l_worker->started_mutex, &l_timeout);
if ( l_ret== ETIMEDOUT ){ if ( l_ret== ETIMEDOUT ){
log_it(L_CRITICAL, "Timeout 5 seconds is out: worker #%u thread don't respond", i); log_it(L_CRITICAL, "Timeout 15 seconds is out: worker #%u thread don't respond", i);
return -2; return -2;
} else if (l_ret != 0){ } else if (l_ret != 0){
log_it(L_CRITICAL, "Can't wait on condition: %d error code", l_ret); log_it(L_CRITICAL, "Can't wait on condition: %d error code", l_ret);
......
...@@ -486,11 +486,12 @@ static void * s_proc_thread_function(void * a_arg) ...@@ -486,11 +486,12 @@ static void * s_proc_thread_function(void * a_arg)
for (size_t i = 0; i < l_thread->poll_count ; i++) { for (size_t i = 0; i < l_thread->poll_count ; i++) {
if ( l_thread->poll[i].fd == -1){ if ( l_thread->poll[i].fd == -1){
if ( l_thread->poll_count){ if ( l_thread->poll_count){
for(size_t j = i; j < l_thread->poll_count-1; j++){ for(size_t j = i; j < l_thread->poll_count-1; j++){
l_thread->poll[j].fd = l_thread->poll[j+1].fd; l_thread->poll[j].fd = l_thread->poll[j+1].fd;
l_thread->esockets[j] = l_thread->esockets[j+1]; l_thread->esockets[j] = l_thread->esockets[j+1];
l_thread->esockets[j]->poll_index = j; if(l_thread->esockets[j])
} l_thread->esockets[j]->poll_index = j;
}
} }
i--; i--;
l_thread->poll_count--; l_thread->poll_count--;
......
...@@ -522,9 +522,10 @@ void *dap_worker_thread(void *arg) ...@@ -522,9 +522,10 @@ void *dap_worker_thread(void *arg)
if ( l_worker->poll[i].fd == -1){ if ( l_worker->poll[i].fd == -1){
if( l_worker->poll_count){ if( l_worker->poll_count){
for(size_t j = i; j < l_worker->poll_count-1; j++){ for(size_t j = i; j < l_worker->poll_count-1; j++){
l_worker->poll[j].fd = l_worker->poll[j+1].fd; l_worker->poll[j].fd = l_worker->poll[j+1].fd;
l_worker->poll_esocket[j] = l_worker->poll_esocket[j+1]; l_worker->poll_esocket[j] = l_worker->poll_esocket[j+1];
l_worker->poll_esocket[j]->poll_index = j; if(l_worker->poll_esocket[j])
l_worker->poll_esocket[j]->poll_index = j;
} }
} }
i--; i--;
......
...@@ -295,14 +295,15 @@ bool s_proc_queue_callback(dap_proc_thread_t * a_thread, void * a_arg ) ...@@ -295,14 +295,15 @@ bool s_proc_queue_callback(dap_proc_thread_t * a_thread, void * a_arg )
return true; return true;
} }
if(_is_user_agent_supported(header->value) == false) { if(header)
log_it(L_DEBUG, "Not supported user agent in request: %s", header->value); if(_is_user_agent_supported(header->value) == false) {
const char* error_msg = "User-Agent version not supported. Update your software"; log_it(L_DEBUG, "Not supported user agent in request: %s", header->value);
_write_response_bad_request(l_http_simple, error_msg); const char* error_msg = "User-Agent version not supported. Update your software";
s_set_writable_flags( l_http_simple); _write_response_bad_request(l_http_simple, error_msg);
dap_proc_thread_assign_on_worker_inter(a_thread, l_http_simple->worker, l_http_simple->esocket); s_set_writable_flags( l_http_simple);
return true; dap_proc_thread_assign_on_worker_inter(a_thread, l_http_simple->worker, l_http_simple->esocket);
} return true;
}
} }
DAP_HTTP_SIMPLE_URL_PROC(l_http_simple->http_client->proc)->proc_callback(l_http_simple,&return_code); DAP_HTTP_SIMPLE_URL_PROC(l_http_simple->http_client->proc)->proc_callback(l_http_simple,&return_code);
......
...@@ -533,8 +533,11 @@ size_t dap_stream_data_proc_read (dap_stream_t *a_stream) ...@@ -533,8 +533,11 @@ size_t dap_stream_data_proc_read (dap_stream_t *a_stream)
bool found_sig=false; bool found_sig=false;
dap_stream_pkt_t * pkt=NULL; dap_stream_pkt_t * pkt=NULL;
char *buf_in = (a_stream->esocket) ? (char*)a_stream->esocket->buf_in : (char*)a_stream->esocket->buf_in; if (!a_stream->esocket)
size_t buf_in_size = (a_stream->esocket) ? a_stream->esocket->buf_in_size : a_stream->esocket->buf_in_size; return 0;
char *buf_in = (char*)a_stream->esocket->buf_in ;
size_t buf_in_size = a_stream->esocket->buf_in_size ;
uint8_t *proc_data = (uint8_t *)buf_in;//a_stream->conn->buf_in; uint8_t *proc_data = (uint8_t *)buf_in;//a_stream->conn->buf_in;
bool proc_data_defrag=false; // We are or not in defrag buffer bool proc_data_defrag=false; // We are or not in defrag buffer
size_t read_bytes_to=0; size_t read_bytes_to=0;
......
...@@ -1295,7 +1295,7 @@ int dap_chain_ledger_tx_cache_check(dap_ledger_t *a_ledger, dap_chain_datum_tx_t ...@@ -1295,7 +1295,7 @@ int dap_chain_ledger_tx_cache_check(dap_ledger_t *a_ledger, dap_chain_datum_tx_t
if (!l_token || !*l_token) { if (!l_token || !*l_token) {
l_token = l_item_out->cache_data.token_tiker; l_token = l_item_out->cache_data.token_tiker;
} }
if (!*l_token) { if (! l_token || !*l_token ) {
log_it(L_WARNING, "No token ticker found in previous transaction"); log_it(L_WARNING, "No token ticker found in previous transaction");
l_err_num = -15; l_err_num = -15;
break; break;
......
...@@ -105,6 +105,7 @@ static void session_data_del_all() ...@@ -105,6 +105,7 @@ static void session_data_del_all()
HASH_DEL(s_chain_net_data, l_sdata); HASH_DEL(s_chain_net_data, l_sdata);
DAP_DELETE(l_sdata); DAP_DELETE(l_sdata);
} }
//HASH_CLEAR(hh,s_chain_net_data);
pthread_mutex_unlock(&s_hash_mutex); pthread_mutex_unlock(&s_hash_mutex);
} }
...@@ -293,7 +294,7 @@ void s_stream_ch_packet_in(dap_stream_ch_t* a_ch, void* a_arg) ...@@ -293,7 +294,7 @@ void s_stream_ch_packet_in(dap_stream_ch_t* a_ch, void* a_arg)
dap_chain_net_t * l_net = dap_chain_net_by_id( l_ch_chain_net_pkt->hdr.net_id ); dap_chain_net_t * l_net = dap_chain_net_by_id( l_ch_chain_net_pkt->hdr.net_id );
if ( l_net == NULL){ if ( l_net == NULL){
char l_err_str[]="ERROR_NET_INVALID_ID"; char l_err_str[]="ERROR_NET_INVALID_ID";
dap_stream_ch_chain_net_pkt_write(a_ch, DAP_STREAM_CH_CHAIN_NET_PKT_TYPE_ERROR , l_net->pub.id, dap_stream_ch_chain_net_pkt_write(a_ch, DAP_STREAM_CH_CHAIN_NET_PKT_TYPE_ERROR , l_ch_chain_net_pkt->hdr.net_id,
l_err_str,sizeof (l_err_str)); l_err_str,sizeof (l_err_str));
dap_stream_ch_set_ready_to_write_unsafe(a_ch, true); dap_stream_ch_set_ready_to_write_unsafe(a_ch, true);
} else { } else {
......
...@@ -1631,7 +1631,8 @@ int s_net_load(const char * a_net_name, uint16_t a_acl_idx) ...@@ -1631,7 +1631,8 @@ int s_net_load(const char * a_net_name, uint16_t a_acl_idx)
DAP_DELETE(l_node_addr); DAP_DELETE(l_node_addr);
l_node_addr = NULL; l_node_addr = NULL;
} }
log_it(L_NOTICE, "Parse node addr " NODE_ADDR_FP_STR " successfully", NODE_ADDR_FP_ARGS(l_node_addr)); if(l_node_addr)
log_it(L_NOTICE, "Parse node addr " NODE_ADDR_FP_STR " successfully", NODE_ADDR_FP_ARGS(l_node_addr));
PVT(l_net)->node_addr = l_node_addr; PVT(l_net)->node_addr = l_node_addr;
//} //}
} }
......
...@@ -289,7 +289,7 @@ static void* thread_one_client_func(void *args) ...@@ -289,7 +289,7 @@ static void* thread_one_client_func(void *args)
} }
else else
free(str_header); free(str_header);
if(marker == 2) { if(marker == 2 && cmd_param_list) {
dap_list_t *list = cmd_param_list; dap_list_t *list = cmd_param_list;
// form command // form command
unsigned int argc = dap_list_length(list); unsigned int argc = dap_list_length(list);
...@@ -722,6 +722,7 @@ int dap_chain_node_cli_check_option( char** argv, int arg_start, int arg_end, co ...@@ -722,6 +722,7 @@ int dap_chain_node_cli_check_option( char** argv, int arg_start, int arg_end, co
*/ */
int dap_chain_node_cli_find_option_val( char** argv, int arg_start, int arg_end, const char *opt_name, const char **opt_value) int dap_chain_node_cli_find_option_val( char** argv, int arg_start, int arg_end, const char *opt_name, const char **opt_value)
{ {
assert(argv);
int arg_index = arg_start; int arg_index = arg_start;
const char *arg_string; const char *arg_string;
int l_ret_pos = 0; int l_ret_pos = 0;
......
...@@ -2217,9 +2217,9 @@ int com_mempool_proc(int argc, char ** argv, void *arg_func, char ** a_str_reply ...@@ -2217,9 +2217,9 @@ int com_mempool_proc(int argc, char ** argv, void *arg_func, char ** a_str_reply
} }
dap_chain_node_cli_cmd_values_parse_net_chain(&arg_index, argc, argv, a_str_reply, &l_chain, &l_net); dap_chain_node_cli_cmd_values_parse_net_chain(&arg_index, argc, argv, a_str_reply, &l_chain, &l_net);
if(!l_net) if(!l_net){
return -1; return -1;
else { }else {
if(*a_str_reply) { if(*a_str_reply) {
DAP_DELETE(*a_str_reply); DAP_DELETE(*a_str_reply);
*a_str_reply = NULL; *a_str_reply = NULL;
...@@ -2229,6 +2229,16 @@ int com_mempool_proc(int argc, char ** argv, void *arg_func, char ** a_str_reply ...@@ -2229,6 +2229,16 @@ int com_mempool_proc(int argc, char ** argv, void *arg_func, char ** a_str_reply
if(l_chain) { if(l_chain) {
l_gdb_group_mempool = dap_chain_net_get_gdb_group_mempool(l_chain); l_gdb_group_mempool = dap_chain_net_get_gdb_group_mempool(l_chain);
l_gdb_group_mempool_tmp = l_gdb_group_mempool; l_gdb_group_mempool_tmp = l_gdb_group_mempool;
}else{
dap_chain_node_cli_set_reply_text(a_str_reply, "no -chain param");
return -1;
}
// If full or light it doesnt work
if(dap_chain_net_get_role(l_net).enums>= NODE_ROLE_FULL){
dap_chain_node_cli_set_reply_text(a_str_reply, "Need master node role or higher for network %s to process this command", l_net->pub.name);
return -1;
} }
const char * l_datum_hash_str = NULL; const char * l_datum_hash_str = NULL;
......
...@@ -209,7 +209,8 @@ char* dap_db_history_tx(dap_chain_hash_fast_t* a_tx_hash, dap_chain_t * a_chain, ...@@ -209,7 +209,8 @@ char* dap_db_history_tx(dap_chain_hash_fast_t* a_tx_hash, dap_chain_t * a_chain,
char *l_dst_to_str = char *l_dst_to_str =
(l_tx_out) ? dap_chain_addr_to_str(&l_tx_out->addr) : (l_tx_out) ? dap_chain_addr_to_str(&l_tx_out->addr) :
NULL; NULL;
dap_string_append_printf(l_str_out, " OUT item %lld %s to %s\n", if(l_tx_out)
dap_string_append_printf(l_str_out, " OUT item %lld %s to %s\n",
l_tx_out->header.value, l_tx_out->header.value,
dap_strlen(l_token_str) > 0 ? l_token_str : "?", dap_strlen(l_token_str) > 0 ? l_token_str : "?",
l_dst_to_str ? l_dst_to_str : "?" l_dst_to_str ? l_dst_to_str : "?"
......
...@@ -660,7 +660,7 @@ dap_chain_cs_dag_event_t* dap_chain_cs_dag_find_event_by_hash(dap_chain_cs_dag_t ...@@ -660,7 +660,7 @@ dap_chain_cs_dag_event_t* dap_chain_cs_dag_find_event_by_hash(dap_chain_cs_dag_t
dap_chain_cs_dag_event_item_t* l_event_item = NULL; dap_chain_cs_dag_event_item_t* l_event_item = NULL;
pthread_rwlock_wrlock( &PVT(a_dag)->events_rwlock ); pthread_rwlock_wrlock( &PVT(a_dag)->events_rwlock );
HASH_FIND(hh, PVT(a_dag)->events ,a_hash,sizeof(*a_hash), l_event_item); HASH_FIND(hh, PVT(a_dag)->events ,a_hash,sizeof(*a_hash), l_event_item);
dap_chain_cs_dag_event_t * l_event = l_event_item->event; dap_chain_cs_dag_event_t * l_event = l_event_item? l_event_item->event: NULL;
pthread_rwlock_unlock( &PVT(a_dag)->events_rwlock ); pthread_rwlock_unlock( &PVT(a_dag)->events_rwlock );
return l_event; return l_event;
} }
...@@ -1103,8 +1103,10 @@ static dap_chain_datum_tx_t* s_chain_callback_atom_iter_find_by_tx_hash(dap_chai ...@@ -1103,8 +1103,10 @@ static dap_chain_datum_tx_t* s_chain_callback_atom_iter_find_by_tx_hash(dap_chai
static dap_chain_atom_ptr_t s_chain_callback_atom_iter_get_next( dap_chain_atom_iter_t * a_atom_iter,size_t * a_atom_size ) static dap_chain_atom_ptr_t s_chain_callback_atom_iter_get_next( dap_chain_atom_iter_t * a_atom_iter,size_t * a_atom_size )
{ {
if (a_atom_iter->cur ){ if (a_atom_iter->cur ){
dap_chain_cs_dag_pvt_t* l_dag_pvt = PVT(DAP_CHAIN_CS_DAG(a_atom_iter->chain));
dap_chain_cs_dag_event_item_t * l_event_item = (dap_chain_cs_dag_event_item_t*) a_atom_iter->cur_item; dap_chain_cs_dag_event_item_t * l_event_item = (dap_chain_cs_dag_event_item_t*) a_atom_iter->cur_item;
a_atom_iter->cur_item = l_event_item->hh.next; a_atom_iter->cur_item = l_event_item->hh.next;
HASH_ITER(hh,l_dag_pvt->events, a_atom_iter->cur_item, l_dag_pvt->events_tmp);
l_event_item = (dap_chain_cs_dag_event_item_t*) a_atom_iter->cur_item; l_event_item = (dap_chain_cs_dag_event_item_t*) a_atom_iter->cur_item;
// if l_event_item=NULL then items are over // if l_event_item=NULL then items are over
a_atom_iter->cur = l_event_item ? l_event_item->event : NULL; a_atom_iter->cur = l_event_item ? l_event_item->event : NULL;
......