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/libdap-stream-ch-chain
1 result
Show changes
Commits on Source (4)
...@@ -243,7 +243,7 @@ void s_stream_ch_packet_in(dap_stream_ch_t* a_ch, void* a_arg) ...@@ -243,7 +243,7 @@ void s_stream_ch_packet_in(dap_stream_ch_t* a_ch, void* a_arg)
l_ch_chain->request_last_ts = dap_db_log_get_last_id(); l_ch_chain->request_last_ts = dap_db_log_get_last_id();
log_it(L_DEBUG, "Requested transactions %llu:%llu", l_request->id_start, log_it(L_DEBUG, "Requested transactions %llu:%llu", l_request->id_start,
(uint64_t ) l_ch_chain->request_last_ts); (uint64_t ) l_ch_chain->request_last_ts);
dap_list_t *l_list = dap_db_log_get_list((time_t) l_request->id_start); dap_list_t *l_list = dap_db_log_get_list(l_request->id_start + 1);
log_it(L_DEBUG, "Got %u items", dap_list_length(l_list)); log_it(L_DEBUG, "Got %u items", dap_list_length(l_list));
if(l_list) { if(l_list) {
// Add it to outgoing list // Add it to outgoing list
...@@ -368,8 +368,10 @@ void s_stream_ch_packet_in(dap_stream_ch_t* a_ch, void* a_arg) ...@@ -368,8 +368,10 @@ void s_stream_ch_packet_in(dap_stream_ch_t* a_ch, void* a_arg)
//check whether to apply the received data into the database //check whether to apply the received data into the database
bool l_no_apply = false; bool l_no_apply = false;
if(l_obj->type == 'd' && !l_read_obj) { if(l_obj->type == 'd') {
l_no_apply = true; // already deleted
if(l_read_obj)
l_no_apply = true;
} }
else if(l_obj->type == 'a') { else if(l_obj->type == 'a') {
bool l_is_the_same_present = false; bool l_is_the_same_present = false;
...@@ -482,10 +484,10 @@ void s_stream_ch_packet_in(dap_stream_ch_t* a_ch, void* a_arg) ...@@ -482,10 +484,10 @@ void s_stream_ch_packet_in(dap_stream_ch_t* a_ch, void* a_arg)
void s_stream_ch_packet_out(dap_stream_ch_t* a_ch, void* a_arg) void s_stream_ch_packet_out(dap_stream_ch_t* a_ch, void* a_arg)
{ {
(void) a_arg; (void) a_arg;
// log_it( L_DEBUG,"s_stream_ch_packet_out");
dap_stream_ch_chain_t *l_ch_chain = DAP_STREAM_CH_CHAIN(a_ch); dap_stream_ch_chain_t *l_ch_chain = DAP_STREAM_CH_CHAIN(a_ch);
log_it( L_DEBUG,"s_stream_ch_packet_out state=%d", l_ch_chain ? l_ch_chain->state : -1);
// log_it( L_DEBUG,"l_ch_chain %X", l_ch_chain ); // log_it( L_DEBUG,"l_ch_chain %X", l_ch_chain );
switch (l_ch_chain->state) { switch (l_ch_chain->state) {
...@@ -545,7 +547,8 @@ void s_stream_ch_packet_out(dap_stream_ch_t* a_ch, void* a_arg) ...@@ -545,7 +547,8 @@ void s_stream_ch_packet_out(dap_stream_ch_t* a_ch, void* a_arg)
} }
} }
*/ */
if ( l_list ) { bool l_is_stop = true;//l_list ? false : true;
while(l_list) {
//log_it(L_DEBUG, "l_list = %X", l_list); //log_it(L_DEBUG, "l_list = %X", l_list);
size_t len = dap_list_length( l_list ); size_t len = dap_list_length( l_list );
...@@ -556,25 +559,36 @@ void s_stream_ch_packet_out(dap_stream_ch_t* a_ch, void* a_arg) ...@@ -556,25 +559,36 @@ void s_stream_ch_packet_out(dap_stream_ch_t* a_ch, void* a_arg)
uint8_t *l_item = dap_db_log_pack( (dap_global_db_obj_t *) l_list->data, &l_item_size_out ); uint8_t *l_item = dap_db_log_pack( (dap_global_db_obj_t *) l_list->data, &l_item_size_out );
if(!l_item || !l_item_size_out) { if(!l_item || !l_item_size_out) {
log_it(L_WARNING, "Log pack returned NULL??? Switch off channel for sending (nothing to send)"); log_it(L_WARNING, "Log pack returned NULL??? data=0x%x (nothing to send) (rest=%d records)", l_list->data, len-1);
l_item_size_out = 0;
//dap_stream_ch_set_ready_to_write(a_ch, false); //dap_stream_ch_set_ready_to_write(a_ch, false);
} }
else { else {
log_it(L_INFO, "Send one global_dr record data=0x%x len=%d (rest=%d records)", l_item, l_item_size_out, len-1);
dap_stream_ch_chain_pkt_write( a_ch, DAP_STREAM_CH_CHAIN_PKT_TYPE_GLOBAL_DB, dap_stream_ch_chain_pkt_write( a_ch, DAP_STREAM_CH_CHAIN_PKT_TYPE_GLOBAL_DB,
l_ch_chain->request_net_id, l_ch_chain->request_chain_id, l_ch_chain->request_net_id, l_ch_chain->request_chain_id,
l_ch_chain->request_cell_id, l_item, l_item_size_out ); l_ch_chain->request_cell_id, l_item, l_item_size_out );
DAP_DELETE(l_item); DAP_DELETE(l_item);
} }
// remove current item from list and go to next item // remove current item from list and go to next item
if(l_list) { dap_chain_global_db_obj_delete((dap_global_db_obj_t *) l_list->data);
l_ch_chain->request_global_db_trs = dap_list_delete_link(l_ch_chain->request_global_db_trs, l_list);
dap_chain_global_db_obj_delete( (dap_global_db_obj_t *) l_list->data ); // nothing was sent
l_ch_chain->request_global_db_trs = dap_list_delete_link( l_ch_chain->request_global_db_trs, l_list ); if(!l_item_size_out) {
l_list = l_ch_chain->request_global_db_trs;
// go to next item
if(l_list)
continue;
// stop global_db sync
else
break;
} }
// sent the record, another will be sent
} else { l_is_stop = false;
break;
}
if(l_is_stop){
log_it(L_DEBUG, "l_list == 0, STOP"); log_it(L_DEBUG, "l_list == 0, STOP");
if(l_ch_chain->state == CHAIN_STATE_SYNC_GLOBAL_DB) { if(l_ch_chain->state == CHAIN_STATE_SYNC_GLOBAL_DB) {
......