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
6a1d2701
Commit
6a1d2701
authored
11 months ago
by
Roman Khlopkov
🔜
Browse files
Options
Downloads
Patches
Plain Diff
[*] Node client archaisms abolishing
parent
26353bec
No related branches found
No related tags found
No related merge requests found
Pipeline
#38150
failed with stage
in 12 minutes and 40 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dap-sdk
+1
-1
1 addition, 1 deletion
dap-sdk
modules/net/dap_chain_node_client.c
+5
-36
5 additions, 36 deletions
modules/net/dap_chain_node_client.c
with
6 additions
and
37 deletions
dap-sdk
@
f030e6c0
Compare
872d5105
...
f030e6c0
Subproject commit
872d510565f32895c7493e620ba47848dab653af
Subproject commit
f030e6c0cb23b019e360d379b4c803713b8a1116
This diff is collapsed.
Click to expand it.
modules/net/dap_chain_node_client.c
+
5
−
36
View file @
6a1d2701
...
...
@@ -82,12 +82,6 @@ static void s_ch_chain_callback_notify_packet_in(dap_chain_ch_t* a_ch_chain, uin
dap_chain_ch_pkt_t
*
a_pkt
,
size_t
a_pkt_data_size
,
void
*
a_arg
);
#ifdef DAP_OS_WINDOWS
#define dap_cond_signal(x) SetEvent(x)
#else
#define dap_cond_signal(x) pthread_cond_broadcast(&x)
#endif
/**
* @brief dap_chain_node_client_init
* @return always 0
...
...
@@ -129,7 +123,7 @@ static void s_stage_status_error_callback(dap_client_t *a_client, void *a_arg)
if
(
l_is_last_attempt
)
{
pthread_mutex_lock
(
&
l_node_client
->
wait_mutex
);
l_node_client
->
state
=
NODE_CLIENT_STATE_DISCONNECTED
;
dap
_cond_signal
(
l_node_client
->
wait_cond
);
pthread
_cond_signal
(
&
l_node_client
->
wait_cond
);
pthread_mutex_unlock
(
&
l_node_client
->
wait_mutex
);
l_node_client
->
esocket_uuid
=
0
;
...
...
@@ -193,7 +187,7 @@ static void s_ch_chain_callback_notify_packet_in2(dap_stream_ch_chain_net_t* a_c
pthread_mutex_lock
(
&
l_node_client
->
wait_mutex
);
l_node_client
->
callbacks_arg
=
DAP_DUP_SIZE
(
a_pkt_net
->
data
,
a_pkt_net_data_size
);
l_node_client
->
state
=
NODE_CLIENT_STATE_VALID_READY
;
dap
_cond_signal
(
l_node_client
->
wait_cond
);
pthread
_cond_signal
(
&
l_node_client
->
wait_cond
);
pthread_mutex_unlock
(
&
l_node_client
->
wait_mutex
);
break
;
...
...
@@ -225,7 +219,7 @@ static void s_ch_chain_callback_notify_packet_R(dap_stream_ch_chain_net_srv_t* a
//s_save_stat_to_database(l_request, l_node_client);
pthread_mutex_lock
(
&
l_node_client
->
wait_mutex
);
l_node_client
->
state
=
NODE_CLIENT_STATE_CHECKED
;
dap
_cond_signal
(
l_node_client
->
wait_cond
);
pthread
_cond_signal
(
&
l_node_client
->
wait_cond
);
pthread_mutex_unlock
(
&
l_node_client
->
wait_mutex
);
break
;
}
...
...
@@ -278,17 +272,12 @@ dap_chain_node_client_t *dap_chain_node_client_create(dap_chain_net_t *a_net,
l_node_client
->
callbacks
=
*
a_callbacks
;
l_node_client
->
info
=
DAP_DUP_SIZE
(
a_node_info
,
sizeof
(
dap_chain_node_info_t
)
+
a_node_info
->
ext_host_len
+
1
);
l_node_client
->
net
=
a_net
;
#ifndef _WIN32
pthread_condattr_t
attr
;
pthread_condattr_init
(
&
attr
);
#ifndef DAP_OS_DARWIN
pthread_condattr_setclock
(
&
attr
,
CLOCK_MONOTONIC
);
#endif
pthread_cond_init
(
&
l_node_client
->
wait_cond
,
&
attr
);
#else
l_node_client
->
wait_cond
=
CreateEventA
(
NULL
,
FALSE
,
FALSE
,
NULL
);
#endif
pthread_mutex_init
(
&
l_node_client
->
wait_mutex
,
NULL
);
l_node_client
->
remote_node_addr
.
uint64
=
a_node_info
->
address
.
uint64
;
return
l_node_client
;
...
...
@@ -306,7 +295,7 @@ bool dap_chain_node_client_connect(dap_chain_node_client_t *a_node_client, const
{
if
(
!
a_node_client
)
return
false
;
a_node_client
->
client
=
dap_client_new
(
NULL
,
s_stage_status_error_callback
,
a_node_client
);
a_node_client
->
client
=
dap_client_new
(
s_stage_status_error_callback
,
a_node_client
);
dap_client_set_is_always_reconnect
(
a_node_client
->
client
,
false
);
a_node_client
->
client
->
_inheritor
=
a_node_client
;
dap_client_set_active_channels_unsafe
(
a_node_client
->
client
,
a_active_channels
);
...
...
@@ -352,15 +341,9 @@ void dap_chain_node_client_close_unsafe(dap_chain_node_client_t *a_node_client)
}
}
// clean client
if
(
a_node_client
->
client
){
a_node_client
->
client
->
delete_callback
=
NULL
;
if
(
a_node_client
->
client
)
dap_client_delete_unsafe
(
a_node_client
->
client
);
}
#ifndef _WIN32
pthread_cond_destroy
(
&
a_node_client
->
wait_cond
);
#else
CloseHandle
(
a_node_client
->
wait_cond
);
#endif
pthread_mutex_destroy
(
&
a_node_client
->
wait_mutex
);
DAP_DEL_Z
(
a_node_client
->
info
);
DAP_DELETE
(
a_node_client
);
...
...
@@ -412,7 +395,6 @@ int dap_chain_node_client_wait(dap_chain_node_client_t *a_client, int a_waited_s
return
-
2
;
}
#ifndef DAP_OS_WINDOWS
// prepare for signal waiting
struct
timespec
l_cond_timeout
;
clock_gettime
(
CLOCK_MONOTONIC
,
&
l_cond_timeout
);
...
...
@@ -440,19 +422,6 @@ int dap_chain_node_client_wait(dap_chain_node_client_t *a_client, int a_waited_s
}
}
pthread_mutex_unlock
(
&
a_client
->
wait_mutex
);
#else
pthread_mutex_unlock
(
&
a_client
->
wait_mutex
);
DWORD
wait
=
WaitForSingleObject
(
a_client
->
wait_cond
,
(
uint32_t
)
a_timeout_ms
);
if
(
wait
==
WAIT_OBJECT_0
&&
(
a_client
->
state
==
a_waited_state
||
a_client
->
state
==
NODE_CLIENT_STATE_ERROR
||
a_client
->
state
==
NODE_CLIENT_STATE_DISCONNECTED
))
{
return
a_client
->
state
==
a_waited_state
?
0
:
-
2
;
}
else
if
(
wait
==
WAIT_TIMEOUT
||
wait
==
WAIT_FAILED
)
{
return
-
1
;
}
#endif
return
ret
;
}
...
...
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