Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
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
Main
Synchronet
Commits
e1959c6d
Commit
e1959c6d
authored
1 year ago
by
Deucе
Browse files
Options
Downloads
Patches
Plain Diff
Remove "same thread" checks, and ensure state is always checked
parent
fa28e4e5
No related branches found
No related tags found
No related merge requests found
Pipeline
#5162
passed
1 year ago
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/sftp/sftp.h
+0
-1
0 additions, 1 deletion
src/sftp/sftp.h
src/sftp/sftp_client.c
+19
-14
19 additions, 14 deletions
src/sftp/sftp_client.c
with
19 additions
and
15 deletions
src/sftp/sftp.h
+
0
−
1
View file @
e1959c6d
...
...
@@ -100,7 +100,6 @@ typedef struct sftp_client_state {
void
*
cb_data
;
sftp_str_t
err_msg
;
sftp_str_t
err_lang
;
pthread_t
thread
;
uint32_t
id
;
uint32_t
err_id
;
uint32_t
err_code
;
...
...
This diff is collapsed.
Click to expand it.
src/sftp/sftp_client.c
+
19
−
14
View file @
e1959c6d
...
...
@@ -69,7 +69,6 @@ sftpc_finish(sftpc_state_t state)
assert
(
state
);
if
(
state
==
NULL
)
return
;
assert
(
state
->
thread
==
pthread_self
());
// TODO: Close all open handles
while
(
!
CloseEvent
(
state
->
recv_event
))
{
assert
(
errno
==
EBUSY
);
...
...
@@ -98,7 +97,6 @@ sftpc_begin(bool (*send_cb)(uint8_t *buf, size_t len, void *cb_data), void *cb_d
ret
->
txp
=
NULL
;
ret
->
send_cb
=
send_cb
;
ret
->
cb_data
=
cb_data
;
ret
->
thread
=
pthread_self
();
ret
->
id
=
0
;
ret
->
err_lang
=
NULL
;
ret
->
err_msg
=
NULL
;
...
...
@@ -119,17 +117,12 @@ check_state(sftpc_state_t state)
assert
(
state
);
if
(
!
state
)
return
false
;
assert
(
state
->
thread
==
pthread_self
());
if
(
state
->
thread
!=
pthread_self
())
return
false
;
return
true
;
}
static
bool
appendheader
(
sftpc_state_t
state
,
uint8_t
type
)
{
if
(
!
check_state
(
state
))
return
false
;
state
->
err_code
=
0
;
state
->
err_id
=
0
;
free_sftp_str
(
state
->
err_lang
);
...
...
@@ -165,9 +158,6 @@ get_result(sftpc_state_t state)
uint8_t
*
txbuf
;
size_t
txsz
;
assert
(
state
->
thread
==
pthread_self
());
if
(
state
->
thread
!=
pthread_self
())
return
false
;
if
(
!
sftp_prep_tx_packet
(
state
->
txp
,
&
txbuf
,
&
txsz
))
return
false
;
if
(
!
state
->
send_cb
(
txbuf
,
txsz
,
state
->
cb_data
))
...
...
@@ -177,7 +167,8 @@ get_result(sftpc_state_t state)
if
(
state
->
rxp
->
type
!=
SSH_FXP_VERSION
)
{
uint32_t
id
=
sftp_get32
(
state
->
rxp
);
if
(
id
!=
state
->
id
)
{
response_handled
(
state
);
free
(
state
->
rxp
);
state
->
rxp
=
NULL
;
return
false
;
}
}
...
...
@@ -202,6 +193,8 @@ handle_error(sftpc_state_t state)
bool
sftpc_init
(
sftpc_state_t
state
)
{
if
(
!
check_state
(
state
))
return
false
;
if
(
!
appendheader
(
state
,
SSH_FXP_INIT
))
return
false
;
if
(
!
append32
(
state
,
SFTP_VERSION
))
...
...
@@ -222,6 +215,8 @@ sftpc_init(sftpc_state_t state)
bool
sftpc_recv
(
sftpc_state_t
state
,
uint8_t
*
buf
,
uint32_t
sz
)
{
if
(
!
check_state
(
state
))
return
false
;
if
(
!
sftp_rx_pkt_append
(
&
state
->
rxp
,
buf
,
sz
))
return
false
;
if
(
sftp_have_full_pkt
(
state
->
rxp
))
...
...
@@ -232,6 +227,8 @@ sftpc_recv(sftpc_state_t state, uint8_t *buf, uint32_t sz)
bool
sftpc_realpath
(
sftpc_state_t
state
,
char
*
path
,
sftp_str_t
*
ret
)
{
if
(
!
check_state
(
state
))
return
false
;
assert
(
ret
);
if
(
ret
==
NULL
)
return
false
;
...
...
@@ -260,9 +257,6 @@ sftpc_realpath(sftpc_state_t state, char *path, sftp_str_t *ret)
static
bool
parse_handle
(
sftpc_state_t
state
,
sftp_str_t
*
handle
)
{
assert
(
state
);
if
(
state
==
NULL
)
return
false
;
assert
(
state
->
rxp
);
if
(
state
->
rxp
==
NULL
)
return
false
;
...
...
@@ -281,6 +275,11 @@ parse_handle(sftpc_state_t state, sftp_str_t *handle)
bool
sftpc_open
(
sftpc_state_t
state
,
char
*
path
,
uint32_t
flags
,
sftp_file_attr_t
attr
,
sftp_dirhandle_t
*
handle
)
{
if
(
!
check_state
(
state
))
return
false
;
assert
(
path
);
if
(
path
==
NULL
)
return
false
;
assert
(
handle
);
if
(
handle
==
NULL
)
return
false
;
...
...
@@ -324,6 +323,8 @@ sftpc_open(sftpc_state_t state, char *path, uint32_t flags, sftp_file_attr_t att
bool
sftpc_close
(
sftpc_state_t
state
,
sftp_filehandle_t
*
handle
)
{
if
(
!
check_state
(
state
))
return
false
;
if
(
!
appendheader
(
state
,
SSH_FXP_CLOSE
))
return
false
;
if
(
!
appendfhandle
(
state
,
*
handle
))
...
...
@@ -339,6 +340,8 @@ sftpc_close(sftpc_state_t state, sftp_filehandle_t *handle)
bool
sftpc_read
(
sftpc_state_t
state
,
sftp_filehandle_t
handle
,
uint64_t
offset
,
uint32_t
len
,
sftp_str_t
*
ret
)
{
if
(
!
check_state
(
state
))
return
false
;
assert
(
ret
);
if
(
ret
==
NULL
)
return
false
;
...
...
@@ -367,6 +370,8 @@ sftpc_read(sftpc_state_t state, sftp_filehandle_t handle, uint64_t offset, uint3
bool
sftpc_write
(
sftpc_state_t
state
,
sftp_filehandle_t
handle
,
uint64_t
offset
,
sftp_str_t
data
)
{
if
(
!
check_state
(
state
))
return
false
;
assert
(
data
);
if
(
data
==
NULL
)
return
false
;
...
...
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