Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
da26e2e6
Commit
da26e2e6
authored
Mar 25, 2021
by
Vladislav Vaintroub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup - reduce duplicate code, in SSL IO error handling.
parent
5a798071
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
23 deletions
+29
-23
vio/viossl.c
vio/viossl.c
+29
-23
No files found.
vio/viossl.c
View file @
da26e2e6
...
@@ -154,6 +154,32 @@ static my_bool ssl_should_retry(Vio *vio, int ret, enum enum_vio_io_event *event
...
@@ -154,6 +154,32 @@ static my_bool ssl_should_retry(Vio *vio, int ret, enum enum_vio_io_event *event
}
}
/**
Handle SSL io error.
@param[in] vio Vio
@param[in] ret return from the failed IO operation
@return 0 - should retry last read/write operation
1 - some error has occured
*/
static
int
handle_ssl_io_error
(
Vio
*
vio
,
int
ret
)
{
enum
enum_vio_io_event
event
;
my_bool
should_wait
;
/* Process the SSL I/O error. */
if
(
!
ssl_should_retry
(
vio
,
ret
,
&
event
,
&
should_wait
))
return
1
;
if
(
!
should_wait
)
return
1
;
/* Attempt to wait for an I/O event. */
return
vio_socket_io_wait
(
vio
,
event
);
}
size_t
vio_ssl_read
(
Vio
*
vio
,
uchar
*
buf
,
size_t
size
)
size_t
vio_ssl_read
(
Vio
*
vio
,
uchar
*
buf
,
size_t
size
)
{
{
int
ret
;
int
ret
;
...
@@ -169,14 +195,7 @@ size_t vio_ssl_read(Vio *vio, uchar *buf, size_t size)
...
@@ -169,14 +195,7 @@ size_t vio_ssl_read(Vio *vio, uchar *buf, size_t size)
{
{
while
((
ret
=
SSL_read
(
ssl
,
buf
,
(
int
)
size
))
<
0
)
while
((
ret
=
SSL_read
(
ssl
,
buf
,
(
int
)
size
))
<
0
)
{
{
enum
enum_vio_io_event
event
;
if
(
handle_ssl_io_error
(
vio
,
ret
))
my_bool
should_wait
;
/* Process the SSL I/O error. */
if
(
!
ssl_should_retry
(
vio
,
ret
,
&
event
,
&
should_wait
))
break
;
/* Attempt to wait for an I/O event. */
if
(
should_wait
&&
vio_socket_io_wait
(
vio
,
event
))
break
;
break
;
}
}
}
}
...
@@ -203,13 +222,7 @@ size_t vio_ssl_write(Vio *vio, const uchar *buf, size_t size)
...
@@ -203,13 +222,7 @@ size_t vio_ssl_write(Vio *vio, const uchar *buf, size_t size)
{
{
while
((
ret
=
SSL_write
(
ssl
,
buf
,
(
int
)
size
))
<
0
)
while
((
ret
=
SSL_write
(
ssl
,
buf
,
(
int
)
size
))
<
0
)
{
{
enum
enum_vio_io_event
event
;
if
(
handle_ssl_io_error
(
vio
,
ret
))
my_bool
should_wait
;
/* Process the SSL I/O error. */
if
(
!
ssl_should_retry
(
vio
,
ret
,
&
event
,
&
should_wait
))
break
;
/* Attempt to wait for an I/O event. */
if
(
should_wait
&&
vio_socket_io_wait
(
vio
,
event
))
break
;
break
;
}
}
}
}
...
@@ -316,14 +329,7 @@ static int ssl_handshake_loop(Vio *vio, SSL *ssl, ssl_handshake_func_t func)
...
@@ -316,14 +329,7 @@ static int ssl_handshake_loop(Vio *vio, SSL *ssl, ssl_handshake_func_t func)
/* Initiate the SSL handshake. */
/* Initiate the SSL handshake. */
while
((
ret
=
func
(
ssl
))
<
1
)
while
((
ret
=
func
(
ssl
))
<
1
)
{
{
enum
enum_vio_io_event
event
;
if
(
handle_ssl_io_error
(
vio
,
ret
))
my_bool
should_wait
;
/* Process the SSL I/O error. */
if
(
!
ssl_should_retry
(
vio
,
ret
,
&
event
,
&
should_wait
))
break
;
/* Wait for I/O so that the handshake can proceed. */
if
(
should_wait
&&
vio_socket_io_wait
(
vio
,
event
))
break
;
break
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment