Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cellframe-sdk
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Code
Merge requests
16
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cellframe
cellframe-sdk
Commits
2f7d3b82
Commit
2f7d3b82
authored
4 years ago
by
Dmitriy A. Gerasimov
Browse files
Options
Downloads
Patches
Plain Diff
[+] Additional check for input data
parent
efb9dee5
No related branches found
No related tags found
2 merge requests
!251
Master
,
!250
Master
Pipeline
#5869
passed with stage
in 13 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CMakeLists.txt
+1
-1
1 addition, 1 deletion
CMakeLists.txt
modules/channel/chain/dap_stream_ch_chain.c
+58
-47
58 additions, 47 deletions
modules/channel/chain/dap_stream_ch_chain.c
with
59 additions
and
48 deletions
CMakeLists.txt
+
1
−
1
View file @
2f7d3b82
...
...
@@ -2,7 +2,7 @@ project(cellframe-sdk C)
cmake_minimum_required
(
VERSION 2.8
)
set
(
CMAKE_C_STANDARD 11
)
set
(
CELLFRAME_SDK_NATIVE_VERSION
"2.6-1
8
"
)
set
(
CELLFRAME_SDK_NATIVE_VERSION
"2.6-1
9
"
)
add_definitions
(
"-DCELLFRAME_SDK_VERSION=
\"
${
CELLFRAME_SDK_NATIVE_VERSION
}
\"
"
)
set
(
DAPSDK_MODULES
""
)
...
...
This diff is collapsed.
Click to expand it.
modules/channel/chain/dap_stream_ch_chain.c
+
58
−
47
View file @
2f7d3b82
...
...
@@ -226,61 +226,72 @@ bool s_chain_pkt_callback(dap_proc_thread_t *a_thread, void *a_arg)
dap_chain_pkt_copy_t
*
l_pkt_copy
=
(
dap_chain_pkt_copy_t
*
)
l_pkt_copy_list
->
data
;
dap_chain_atom_ptr_t
l_atom_copy
=
(
dap_chain_atom_ptr_t
)
l_pkt_copy
->
pkt_data
;
uint64_t
l_atom_copy_size
=
l_pkt_copy
->
pkt_data_size
;
dap_hash_fast
(
l_atom_copy
,
l_atom_copy_size
,
&
l_atom_hash
);
dap_chain_atom_iter_t
*
l_atom_iter
=
l_chain
->
callback_atom_iter_create
(
l_chain
);
size_t
l_atom_size
=
0
;
if
(
l_chain
->
callback_atom_find_by_hash
(
l_atom_iter
,
&
l_atom_hash
,
&
l_atom_size
)
==
NULL
)
{
dap_chain_atom_verify_res_t
l_atom_add_res
=
l_chain
->
callback_atom_add
(
l_chain
,
l_atom_copy
,
l_atom_copy_size
);
if
(
l_atom_add_res
==
ATOM_ACCEPT
&&
dap_chain_has_file_store
(
l_chain
))
{
// append to file
dap_chain_cell_t
*
l_cell
=
dap_chain_cell_create_fill
(
l_chain
,
l_ch_chain
->
request_cell_id
);
int
l_res
;
if
(
l_cell
)
{
// add one atom only
l_res
=
dap_chain_cell_file_append
(
l_cell
,
l_atom_copy
,
l_atom_copy_size
);
// rewrite all file
//l_res = dap_chain_cell_file_update(l_cell);
if
(
l_res
<
0
)
{
log_it
(
L_ERROR
,
"Can't save event 0x%x to the file '%s'"
,
l_atom_hash
,
l_cell
?
l_cell
->
file_storage_path
:
"[null]"
);
}
// add all atoms from treshold
if
(
l_chain
->
callback_atom_add_from_treshold
){
dap_chain_atom_ptr_t
l_atom_treshold
;
do
{
size_t
l_atom_treshold_size
;
// add into ledger
log_it
(
L_DEBUG
,
"Try to add atom from treshold"
);
l_atom_treshold
=
l_chain
->
callback_atom_add_from_treshold
(
l_chain
,
&
l_atom_treshold_size
);
// add into file
if
(
l_atom_treshold
)
{
l_res
=
dap_chain_cell_file_append
(
l_cell
,
l_atom_treshold
,
l_atom_treshold_size
);
log_it
(
L_DEBUG
,
"Added atom from treshold"
);
if
(
l_res
<
0
)
{
log_it
(
L_ERROR
,
"Can't save event 0x%x from treshold to the file '%s'"
,
l_atom_treshold
,
l_cell
?
l_cell
->
file_storage_path
:
"[null]"
);
if
(
l_atom_copy_size
&&
l_pkt_copy
&&
l_atom_copy
){
dap_hash_fast
(
l_atom_copy
,
l_atom_copy_size
,
&
l_atom_hash
);
dap_chain_atom_iter_t
*
l_atom_iter
=
l_chain
->
callback_atom_iter_create
(
l_chain
);
size_t
l_atom_size
=
0
;
if
(
l_chain
->
callback_atom_find_by_hash
(
l_atom_iter
,
&
l_atom_hash
,
&
l_atom_size
)
==
NULL
)
{
dap_chain_atom_verify_res_t
l_atom_add_res
=
l_chain
->
callback_atom_add
(
l_chain
,
l_atom_copy
,
l_atom_copy_size
);
if
(
l_atom_add_res
==
ATOM_ACCEPT
&&
dap_chain_has_file_store
(
l_chain
))
{
// append to file
dap_chain_cell_t
*
l_cell
=
dap_chain_cell_create_fill
(
l_chain
,
l_ch_chain
->
request_cell_id
);
int
l_res
;
if
(
l_cell
)
{
// add one atom only
l_res
=
dap_chain_cell_file_append
(
l_cell
,
l_atom_copy
,
l_atom_copy_size
);
// rewrite all file
//l_res = dap_chain_cell_file_update(l_cell);
if
(
l_res
<
0
)
{
log_it
(
L_ERROR
,
"Can't save event 0x%x to the file '%s'"
,
l_atom_hash
,
l_cell
?
l_cell
->
file_storage_path
:
"[null]"
);
}
// add all atoms from treshold
if
(
l_chain
->
callback_atom_add_from_treshold
){
dap_chain_atom_ptr_t
l_atom_treshold
;
do
{
size_t
l_atom_treshold_size
;
// add into ledger
log_it
(
L_DEBUG
,
"Try to add atom from treshold"
);
l_atom_treshold
=
l_chain
->
callback_atom_add_from_treshold
(
l_chain
,
&
l_atom_treshold_size
);
// add into file
if
(
l_atom_treshold
)
{
l_res
=
dap_chain_cell_file_append
(
l_cell
,
l_atom_treshold
,
l_atom_treshold_size
);
log_it
(
L_DEBUG
,
"Added atom from treshold"
);
if
(
l_res
<
0
)
{
log_it
(
L_ERROR
,
"Can't save event 0x%x from treshold to the file '%s'"
,
l_atom_treshold
,
l_cell
?
l_cell
->
file_storage_path
:
"[null]"
);
}
}
}
while
(
l_atom_treshold
);
}
while
(
l_atom_treshold
);
}
// delete cell and close file
dap_chain_cell_delete
(
l_cell
);
}
else
{
log_it
(
L_ERROR
,
"Can't get cell for cell_id 0x%x for save event to file"
,
l_ch_chain
->
request_cell_id
);
// delete cell and close file
dap_chain_cell_delete
(
l_cell
);
}
else
{
log_it
(
L_ERROR
,
"Can't get cell for cell_id 0x%x for save event to file"
,
l_ch_chain
->
request_cell_id
);
}
}
}
if
(
l_atom_add_res
==
ATOM_PASS
)
if
(
l_atom_add_res
==
ATOM_PASS
)
DAP_DELETE
(
l_atom_copy
);
}
else
{
DAP_DELETE
(
l_atom_copy
);
}
else
{
DAP_DELETE
(
l_atom_copy
);
}
l_chain
->
callback_atom_iter_delete
(
l_atom_iter
);
}
else
{
if
(
!
l_pkt_copy
)
log_it
(
L_WARNING
,
"packet copy is NULL"
);
if
(
!
l_pkt_copy_list
)
log_it
(
L_WARNING
,
"packet copy list is NULL"
);
if
(
l_atom_copy_size
)
log_it
(
L_WARNING
,
"Atom copy size is zero"
);
}
l_chain
->
callback_atom_iter_delete
(
l_atom_iter
);
DAP_DELETE
(
l_pkt_copy
);
DAP_DELETE
(
l_pkt_copy_list
);
if
(
l_pkt_copy
)
DAP_DELETE
(
l_pkt_copy
);
if
(
l_pkt_copy_list
)
DAP_DELETE
(
l_pkt_copy_list
);
}
else
log_it
(
L_WARNING
,
"In proc thread got CHAINS stream ch packet with zero data"
);
dap_events_socket_assign_on_worker_mt
(
l_ch
->
stream
->
esocket
,
l_ch
->
stream_worker
->
worker
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment