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
7d38d05c
Commit
7d38d05c
authored
Sep 11, 2015
by
Alexander Alashkin
Committed by
Sergey Lyubka
Sep 21, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use updated sockets
PUBLISHED_FROM=30231da54720c709ce98cd0ab208cf9b06814eab
parent
33bad047
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
24 deletions
+13
-24
mongoose.c
mongoose.c
+13
-24
No files found.
mongoose.c
View file @
7d38d05c
...
...
@@ -1991,7 +1991,7 @@ NS_INTERNAL struct mg_connection *mg_create_connection(
/* Associate a socket to a connection and and add to the manager. */
NS_INTERNAL
void
mg_set_sock
(
struct
mg_connection
*
nc
,
sock_t
sock
)
{
#if
ndef NS_CC3200
#if
!defined(NS_CC3200) && !defined(NS_ESP8266)
/* Can't get non-blocking connect to work.
* TODO(rojer): Figure out why it fails where blocking succeeds.
*/
...
...
@@ -2375,17 +2375,17 @@ static void mg_ssl_begin(struct mg_connection *nc) {
static
void
mg_read_from_socket
(
struct
mg_connection
*
conn
)
{
char
buf
[
NS_READ_BUFFER_SIZE
];
int
n
=
0
,
to_recv
;
int
n
=
0
;
if
(
conn
->
flags
&
NSF_CONNECTING
)
{
int
ok
=
1
,
ret
;
#if
ndef NS_CC3200
#if
!defined(NS_CC3200) && !defined(NS_ESP8266)
socklen_t
len
=
sizeof
(
ok
);
#endif
(
void
)
ret
;
#if
def NS_CC3200
/* On CC3200 we use blocking connect. If we got as far as this,
#if
defined(NS_CC3200) || defined(NS_ESP8266)
/* On CC3200
and ESP8266
we use blocking connect. If we got as far as this,
* this means connect() was successful.
* TODO(rojer): Figure out why it fails where blocking succeeds.
*/
...
...
@@ -2428,29 +2428,14 @@ static void mg_read_from_socket(struct mg_connection *conn) {
}
}
else
#endif
{
to_recv
=
recv_avail_size
(
conn
,
sizeof
(
buf
));
while
((
n
=
(
int
)
NS_RECV_FUNC
(
conn
->
sock
,
buf
,
to_recv
,
0
))
>
0
)
{
while
((
n
=
(
int
)
NS_RECV_FUNC
(
conn
->
sock
,
buf
,
recv_avail_size
(
conn
,
sizeof
(
buf
)),
0
))
>
0
)
{
DBG
((
"%p %d bytes (PLAIN) <- %d"
,
conn
,
n
,
conn
->
sock
));
mbuf_append
(
&
conn
->
recv_mbuf
,
buf
,
n
);
mg_call
(
conn
,
NS_RECV
,
&
n
);
if
(
conn
->
flags
&
NSF_CLOSE_IMMEDIATELY
)
break
;
#ifdef NS_ESP8266
/*
* TODO(alashkin): ESP/RTOS recv implementation tend to block
* even in non-blocking mode, so, break the loop
* if received size less than buffer size
* and wait for next select()
* Some of RTOS specific call missed?
*/
if
(
to_recv
>
n
)
{
break
;
}
to_recv
=
recv_avail_size
(
conn
,
sizeof
(
buf
));
#endif
}
DBG
((
"recv returns %d"
,
n
));
}
if
(
mg_is_error
(
n
))
{
conn
->
flags
|=
NSF_CLOSE_IMMEDIATELY
;
...
...
@@ -2592,6 +2577,7 @@ static void mg_mgr_handle_connection(struct mg_connection *nc, int fd_flags,
(
int
)
nc
->
recv_mbuf
.
len
,
(
int
)
nc
->
send_mbuf
.
len
));
}
#ifndef NS_DISABLE_SOCKETPAIR
static
void
mg_mgr_handle_ctl_sock
(
struct
mg_mgr
*
mgr
)
{
struct
ctl_msg
ctl_msg
;
int
len
=
...
...
@@ -2604,6 +2590,7 @@ static void mg_mgr_handle_ctl_sock(struct mg_mgr *mgr) {
}
}
}
#endif
#if NS_MGR_EV_MGR == 1
/* epoll() */
...
...
@@ -2798,10 +2785,12 @@ time_t mg_mgr_poll(struct mg_mgr *mgr, int milli) {
now
=
time
(
NULL
);
DBG
((
"select @ %ld num_ev=%d"
,
(
long
)
now
,
num_selected
));
#ifndef NS_DISABLE_SOCKETPAIR
if
(
num_selected
>
0
&&
mgr
->
ctl
[
1
]
!=
INVALID_SOCKET
&&
FD_ISSET
(
mgr
->
ctl
[
1
],
&
read_set
))
{
mg_mgr_handle_ctl_sock
(
mgr
);
}
#endif
for
(
nc
=
mgr
->
active_connections
;
nc
!=
NULL
;
nc
=
tmp
)
{
int
fd_flags
=
0
;
...
...
@@ -2860,7 +2849,7 @@ NS_INTERNAL struct mg_connection *mg_finish_connect(struct mg_connection *nc,
return
NULL
;
}
#if
ndef NS_CC3200
#if
!defined(NS_CC3200) && !defined(NS_ESP8266)
mg_set_non_blocking_mode
(
sock
);
#endif
rc
=
(
proto
==
SOCK_DGRAM
)
?
0
:
connect
(
sock
,
&
sa
->
sa
,
sizeof
(
sa
->
sin
));
...
...
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