Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongoose
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esp
mongoose
Commits
b738fdbf
Commit
b738fdbf
authored
Jul 08, 2014
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated net skeleton
parent
b5704850
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
12 deletions
+15
-12
mongoose.c
mongoose.c
+15
-12
No files found.
mongoose.c
View file @
b738fdbf
...
...
@@ -713,6 +713,15 @@ int ns_hexdump(const void *buf, int len, char *dst, int dst_len) {
return
n
;
}
#ifdef NS_ENABLE_SSL
static
int
ns_ssl_err
(
struct
ns_connection
*
conn
,
int
res
)
{
int
ssl_err
=
SSL_get_error
(
conn
->
ssl
,
res
);
if
(
ssl_err
==
SSL_ERROR_WANT_READ
)
conn
->
flags
|=
NSF_WANT_READ
;
if
(
ssl_err
==
SSL_ERROR_WANT_WRITE
)
conn
->
flags
|=
NSF_WANT_WRITE
;
return
ssl_err
;
}
#endif
static
void
ns_read_from_socket
(
struct
ns_connection
*
conn
)
{
char
buf
[
2048
];
int
n
=
0
;
...
...
@@ -726,10 +735,7 @@ static void ns_read_from_socket(struct ns_connection *conn) {
#ifdef NS_ENABLE_SSL
if
(
ret
==
0
&&
ok
==
0
&&
conn
->
ssl
!=
NULL
)
{
int
res
=
SSL_connect
(
conn
->
ssl
);
int
ssl_err
=
SSL_get_error
(
conn
->
ssl
,
res
);
DBG
((
"%p %d wres %d %d"
,
conn
,
conn
->
flags
,
res
,
ssl_err
));
if
(
ssl_err
==
SSL_ERROR_WANT_READ
)
conn
->
flags
|=
NSF_WANT_READ
;
if
(
ssl_err
==
SSL_ERROR_WANT_WRITE
)
conn
->
flags
|=
NSF_WANT_WRITE
;
int
ssl_err
=
ns_ssl_err
(
conn
,
res
);
if
(
res
==
1
)
{
conn
->
flags
|=
NSF_SSL_HANDSHAKE_DONE
;
}
else
if
(
ssl_err
==
SSL_ERROR_WANT_READ
||
...
...
@@ -760,12 +766,10 @@ static void ns_read_from_socket(struct ns_connection *conn) {
iobuf_append
(
&
conn
->
recv_iobuf
,
buf
,
n
);
ns_call
(
conn
,
NS_RECV
,
&
n
);
}
ns_ssl_err
(
conn
,
n
);
}
else
{
int
res
=
SSL_accept
(
conn
->
ssl
);
int
ssl_err
=
SSL_get_error
(
conn
->
ssl
,
res
);
DBG
((
"%p %d rres %d %d"
,
conn
,
conn
->
flags
,
res
,
ssl_err
));
if
(
ssl_err
==
SSL_ERROR_WANT_READ
)
conn
->
flags
|=
NSF_WANT_READ
;
if
(
ssl_err
==
SSL_ERROR_WANT_WRITE
)
conn
->
flags
|=
NSF_WANT_WRITE
;
int
ssl_err
=
ns_ssl_err
(
conn
,
res
);
if
(
res
==
1
)
{
conn
->
flags
|=
NSF_SSL_HANDSHAKE_DONE
;
}
else
if
(
ssl_err
==
SSL_ERROR_WANT_READ
||
...
...
@@ -798,10 +802,9 @@ static void ns_write_to_socket(struct ns_connection *conn) {
#ifdef NS_ENABLE_SSL
if
(
conn
->
ssl
!=
NULL
)
{
n
=
SSL_write
(
conn
->
ssl
,
io
->
buf
,
io
->
len
);
if
(
n
<
0
)
{
int
ssl_err
=
SSL_get_error
(
conn
->
ssl
,
n
);
DBG
((
"%p %d %d"
,
conn
,
n
,
ssl_err
));
if
(
ssl_err
==
2
||
ssl_err
==
3
)
{
if
(
n
<=
0
)
{
int
ssl_err
=
ns_ssl_err
(
conn
,
n
);
if
(
ssl_err
==
SSL_ERROR_WANT_READ
||
ssl_err
==
SSL_ERROR_WANT_WRITE
)
{
return
;
// Call us again
}
else
{
conn
->
flags
|=
NSF_CLOSE_IMMEDIATELY
;
...
...
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