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
8115ce1d
Commit
8115ce1d
authored
Mar 27, 2014
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handling SSL_write() error
parent
3558b587
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
8 deletions
+17
-8
mongoose.c
mongoose.c
+17
-8
No files found.
mongoose.c
View file @
8115ce1d
...
@@ -162,19 +162,20 @@ int iobuf_append(struct iobuf *, const void *data, int data_size);
...
@@ -162,19 +162,20 @@ int iobuf_append(struct iobuf *, const void *data, int data_size);
void
iobuf_remove
(
struct
iobuf
*
,
int
data_size
);
void
iobuf_remove
(
struct
iobuf
*
,
int
data_size
);
// Net skeleton interface
// Net skeleton interface
// Events. Meaning of event parameter (evp) is given in the comment.
enum
ns_event
{
enum
ns_event
{
NS_POLL
,
// Sent to each connection on each call to ns_server_poll()
NS_POLL
,
// Sent to each connection on each call to ns_server_poll()
NS_ACCEPT
,
//
Listening socket accept()-ed new connection
NS_ACCEPT
,
//
New connection accept()-ed. union socket_address *remote_addr
NS_CONNECT
,
//
Connection made by ns_connect() succeeded or failed
NS_CONNECT
,
//
connect() succeeded or failed. int *success_status
NS_RECV
,
// Data has benn received
NS_RECV
,
// Data has benn received
. int *num_bytes
NS_SEND
,
// Data has been written to a socket
NS_SEND
,
// Data has been written to a socket
. int *num_bytes
NS_CLOSE
// Connection is closed
NS_CLOSE
// Connection is closed
. NULL
};
};
// Callback function (event handler) prototype, must be defined by user.
// Callback function (event handler) prototype, must be defined by user.
// Net skeleton will call event handler, passing events defined above.
// Net skeleton will call event handler, passing events defined above.
struct
ns_connection
;
struct
ns_connection
;
typedef
void
(
*
ns_callback_t
)(
struct
ns_connection
*
,
enum
ns_event
,
void
*
);
typedef
void
(
*
ns_callback_t
)(
struct
ns_connection
*
,
enum
ns_event
,
void
*
evp
);
struct
ns_server
{
struct
ns_server
{
void
*
server_data
;
void
*
server_data
;
...
@@ -576,7 +577,6 @@ static struct ns_connection *accept_conn(struct ns_server *server) {
...
@@ -576,7 +577,6 @@ static struct ns_connection *accept_conn(struct ns_server *server) {
// NOTE(lsm): on Windows, sock is always > FD_SETSIZE
// NOTE(lsm): on Windows, sock is always > FD_SETSIZE
if
((
sock
=
accept
(
server
->
listening_sock
,
&
sa
.
sa
,
&
len
))
==
INVALID_SOCKET
)
{
if
((
sock
=
accept
(
server
->
listening_sock
,
&
sa
.
sa
,
&
len
))
==
INVALID_SOCKET
)
{
closesocket
(
sock
);
}
else
if
((
c
=
(
struct
ns_connection
*
)
NS_MALLOC
(
sizeof
(
*
c
)))
==
NULL
||
}
else
if
((
c
=
(
struct
ns_connection
*
)
NS_MALLOC
(
sizeof
(
*
c
)))
==
NULL
||
memset
(
c
,
0
,
sizeof
(
*
c
))
==
NULL
)
{
memset
(
c
,
0
,
sizeof
(
*
c
))
==
NULL
)
{
closesocket
(
sock
);
closesocket
(
sock
);
...
@@ -735,6 +735,15 @@ static void ns_write_to_socket(struct ns_connection *conn) {
...
@@ -735,6 +735,15 @@ static void ns_write_to_socket(struct ns_connection *conn) {
#ifdef NS_ENABLE_SSL
#ifdef NS_ENABLE_SSL
if
(
conn
->
ssl
!=
NULL
)
{
if
(
conn
->
ssl
!=
NULL
)
{
n
=
SSL_write
(
conn
->
ssl
,
io
->
buf
,
io
->
len
);
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
)
{
return
;
// Call us again
}
else
{
conn
->
flags
|=
NSF_CLOSE_IMMEDIATELY
;
}
}
}
else
}
else
#endif
#endif
{
n
=
send
(
conn
->
sock
,
io
->
buf
,
io
->
len
,
0
);
}
{
n
=
send
(
conn
->
sock
,
io
->
buf
,
io
->
len
,
0
);
}
...
@@ -4499,7 +4508,7 @@ static void hexdump(struct ns_connection *nc, const char *path,
...
@@ -4499,7 +4508,7 @@ static void hexdump(struct ns_connection *nc, const char *path,
is_sent
?
"->"
:
"<-"
,
is_sent
?
"->"
:
"<-"
,
mc
->
mg_conn
.
remote_ip
,
mc
->
mg_conn
.
remote_port
,
mc
->
mg_conn
.
remote_ip
,
mc
->
mg_conn
.
remote_port
,
num_bytes
);
num_bytes
);
if
((
buf
=
malloc
(
buf_size
))
!=
NULL
)
{
if
((
buf
=
(
char
*
)
malloc
(
buf_size
))
!=
NULL
)
{
ns_hexdump
(
io
->
buf
+
(
is_sent
?
0
:
io
->
len
)
-
(
is_sent
?
0
:
num_bytes
),
ns_hexdump
(
io
->
buf
+
(
is_sent
?
0
:
io
->
len
)
-
(
is_sent
?
0
:
num_bytes
),
num_bytes
,
buf
,
buf_size
);
num_bytes
,
buf
,
buf_size
);
fprintf
(
fp
,
"%s"
,
buf
);
fprintf
(
fp
,
"%s"
,
buf
);
...
...
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