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
18
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
0f8c4a14
Commit
0f8c4a14
authored
3 years ago
by
ruslan.laishev
💬
Browse files
Options
Downloads
Patches
Plain Diff
Added checks to prevent crash on unitialized contexts.
parent
e76211f8
No related branches found
No related tags found
No related merge requests found
Pipeline
#12401
passed with stage
in 5 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
dap-sdk/net/core/dap_events.c
+26
-9
26 additions, 9 deletions
dap-sdk/net/core/dap_events.c
dap-sdk/net/core/include/dap_proc_queue.h
+1
-1
1 addition, 1 deletion
dap-sdk/net/core/include/dap_proc_queue.h
dap-sdk/net/core/include/dap_worker.h
+1
-1
1 addition, 1 deletion
dap-sdk/net/core/include/dap_worker.h
with
28 additions
and
11 deletions
dap-sdk/net/core/dap_events.c
+
26
−
9
View file @
0f8c4a14
...
...
@@ -98,7 +98,7 @@ typedef cpuset_t cpu_set_t; // Adopt BSD CPU setstructure to POSIX variant
#define LOG_TAG "dap_events"
static
bool
s_workers_init
=
false
;
static
int
s_workers_init
=
0
;
static
uint32_t
s_threads_count
=
1
;
static
dap_worker_t
**
s_workers
=
NULL
;
static
dap_thread_t
*
s_threads
=
NULL
;
...
...
@@ -214,15 +214,16 @@ int dap_events_init( uint32_t a_threads_count, size_t a_conn_timeout )
if
(
!
s_workers
||
!
s_threads
)
return
-
1
;
s_workers_init
=
true
;
dap_worker_init
(
a_conn_timeout
);
if
(
dap_events_socket_init
()
!=
0
)
{
log_it
(
L_CRITICAL
,
"Can't init client submodule dap_events_socket_init( )"
);
goto
err
;
}
log_it
(
L_NOTICE
,
"Initialized event socket reactor for %u threads"
,
s_threads_count
);
s_workers_init
=
1
;
return
0
;
err:
...
...
@@ -246,6 +247,8 @@ void dap_events_deinit( )
if
(
s_workers
)
DAP_DELETE
(
s_workers
);
s_workers_init
=
0
;
}
/**
...
...
@@ -313,6 +316,9 @@ void dap_events_remove_and_delete_socket_unsafe(dap_events_t *a_events, dap_even
int
dap_events_start
(
dap_events_t
*
a_events
)
{
if
(
!
s_workers_init
)
log_it
(
L_CRITICAL
,
"Event socket reactor has not been fired, use dap_events_init() first"
);
for
(
uint32_t
i
=
0
;
i
<
s_threads_count
;
i
++
)
{
dap_worker_t
*
l_worker
=
DAP_NEW_Z
(
dap_worker_t
);
...
...
@@ -413,6 +419,9 @@ int dap_events_wait( dap_events_t *a_events )
*/
void
dap_events_stop_all
(
)
{
if
(
!
s_workers_init
)
log_it
(
L_CRITICAL
,
"Event socket reactor has not been fired, use dap_events_init() first"
);
for
(
uint32_t
i
=
0
;
i
<
s_threads_count
;
i
++
)
{
dap_events_socket_event_signal
(
s_workers
[
i
]
->
event_exit
,
1
);
}
...
...
@@ -427,12 +436,13 @@ void dap_events_stop_all( )
uint32_t
dap_events_worker_get_index_min
(
)
{
uint32_t
min
=
0
;
uint32_t
i
;
for
(
i
=
1
;
i
<
s_threads_count
;
i
++
)
{
if
(
!
s_workers_init
)
log_it
(
L_CRITICAL
,
"Event socket reactor has not been fired, use dap_events_init() first"
);
if
(
s_workers
[
min
]
->
event_sockets_count
>
s_workers
[
i
]
->
event_sockets_count
)
min
=
i
;
for
(
int
i
=
1
;
i
<
s_threads_count
;
i
++
)
{
if
(
s_workers
[
min
]
->
event_sockets_count
>
s_workers
[
i
]
->
event_sockets_count
)
min
=
i
;
}
return
min
;
...
...
@@ -449,6 +459,9 @@ uint32_t dap_events_worker_get_count()
*/
dap_worker_t
*
dap_events_worker_get_auto
(
)
{
if
(
!
s_workers_init
)
log_it
(
L_CRITICAL
,
"Event socket reactor has not been fired, use dap_events_init() first"
);
return
s_workers
[
dap_events_worker_get_index_min
()];
}
...
...
@@ -459,6 +472,9 @@ dap_worker_t *dap_events_worker_get_auto( )
*/
dap_worker_t
*
dap_events_worker_get
(
uint8_t
a_index
)
{
if
(
!
s_workers_init
)
log_it
(
L_CRITICAL
,
"Event socket reactor has not been fired, use dap_events_init() first"
);
return
(
a_index
<
s_threads_count
)
?
s_workers
[
a_index
]
:
NULL
;
}
...
...
@@ -467,9 +483,10 @@ dap_worker_t * dap_events_worker_get(uint8_t a_index)
*/
void
dap_events_worker_print_all
(
)
{
if
(
!
s_workers_init
)
log_it
(
L_CRITICAL
,
"Event socket reactor has not been fired, use dap_events_init() first"
);
for
(
int
i
=
0
;
i
<
s_threads_count
;
i
++
)
{
log_it
(
L_INFO
,
"Worker: %d, count open connections: %d"
,
s_workers
[
i
]
->
id
,
s_workers
[
i
]
->
event_sockets_count
);
log_it
(
L_INFO
,
"Worker: %d, count open connections: %d"
,
s_workers
[
i
]
->
id
,
s_workers
[
i
]
->
event_sockets_count
);
}
}
This diff is collapsed.
Click to expand it.
dap-sdk/net/core/include/dap_proc_queue.h
+
1
−
1
View file @
0f8c4a14
...
...
@@ -25,7 +25,7 @@
typedef
struct
dap_proc_thread
dap_proc_thread_t
;
typedef
bool
(
*
dap_proc_queue_callback_t
)(
dap_proc_thread_t
*
,
void
*
);
// Callback for processor. Returns true if
typedef
int
(
*
dap_proc_queue_callback_t
)(
dap_proc_thread_t
*
,
void
*
);
// Callback for processor. Returns true if
// we want to stop callback execution and
// not to go on next loop
enum
{
...
...
This diff is collapsed.
Click to expand it.
dap-sdk/net/core/include/dap_worker.h
+
1
−
1
View file @
0f8c4a14
...
...
@@ -38,7 +38,7 @@ typedef struct dap_worker
dap_proc_queue_t
*
proc_queue
;
dap_events_socket_t
*
proc_queue_input
;
atomic_uin
t
event_sockets_count
;
uint32_
t
event_sockets_count
;
pthread_rwlock_t
esocket_rwlock
;
dap_events_socket_t
*
esockets
;
// Hashmap of event sockets
...
...
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