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
2b4e5448
Commit
2b4e5448
authored
Oct 19, 2015
by
Deomid Ryabkov
Committed by
Marko Mikulicic
Oct 21, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move "connect done" logic from mg_read_from_socket
PUBLISHED_FROM=318cc110d8b012cf75cb02dfc68a8215faa93fe7
parent
ee042a34
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
33 deletions
+30
-33
mongoose.c
mongoose.c
+30
-33
No files found.
mongoose.c
View file @
2b4e5448
...
...
@@ -2458,42 +2458,25 @@ static void mg_ssl_begin(struct mg_connection *nc) {
}
#endif
/* MG_ENABLE_SSL */
static
void
mg_read_from_socket
(
struct
mg_connection
*
conn
)
{
char
buf
[
MG_READ_BUFFER_SIZE
];
int
n
=
0
;
if
(
conn
->
flags
&
MG_F_CONNECTING
)
{
int
ok
=
1
,
ret
;
#if !defined(MG_CC3200) && !defined(MG_ESP8266)
socklen_t
len
=
sizeof
(
ok
);
#endif
(
void
)
ret
;
#if defined(MG_CC3200) || defined(MG_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.
*/
mg_set_non_blocking_mode
(
conn
->
sock
);
ret
=
ok
=
0
;
#else
ret
=
getsockopt
(
conn
->
sock
,
SOL_SOCKET
,
SO_ERROR
,
(
char
*
)
&
ok
,
&
len
);
#endif
static
void
mg_connect_done
(
struct
mg_connection
*
conn
,
int
err
)
{
#ifdef MG_ENABLE_SSL
if
(
ret
==
0
&&
ok
==
0
&&
conn
->
ssl
!=
NULL
)
{
mg_ssl_begin
(
conn
);
}
if
(
err
==
0
&&
conn
->
ssl
!=
NULL
)
{
mg_ssl_begin
(
conn
);
}
#endif
DBG
((
"%p connect ok=%d"
,
conn
,
ok
));
if
(
ok
!=
0
)
{
conn
->
flags
|=
MG_F_CLOSE_IMMEDIATELY
;
}
else
{
conn
->
flags
&=
~
MG_F_CONNECTING
;
}
mg_call
(
conn
,
MG_EV_CONNECT
,
&
ok
);
return
;
DBG
((
"%p connect, err=%d"
,
conn
,
err
));
if
(
err
!=
0
)
{
conn
->
flags
|=
MG_F_CLOSE_IMMEDIATELY
;
}
else
{
conn
->
flags
&=
~
MG_F_CONNECTING
;
}
mg_call
(
conn
,
MG_EV_CONNECT
,
&
err
);
return
;
}
static
void
mg_read_from_socket
(
struct
mg_connection
*
conn
)
{
int
n
=
0
;
char
buf
[
MG_READ_BUFFER_SIZE
];
#ifdef MG_ENABLE_SSL
if
(
conn
->
ssl
!=
NULL
)
{
if
(
conn
->
flags
&
MG_F_SSL_HANDSHAKE_DONE
)
{
...
...
@@ -2630,7 +2613,21 @@ static void mg_mgr_handle_connection(struct mg_connection *nc, int fd_flags,
if
(
nc
->
flags
&
MG_F_CONNECTING
)
{
if
(
fd_flags
!=
0
)
{
mg_read_from_socket
(
nc
);
int
err
=
1
;
#if !defined(MG_CC3200) && !defined(MG_ESP8266)
socklen_t
len
=
sizeof
(
err
);
int
ret
=
getsockopt
(
nc
->
sock
,
SOL_SOCKET
,
SO_ERROR
,
(
char
*
)
&
err
,
&
len
);
if
(
ret
!=
0
)
err
=
1
;
#else
/* 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.
*/
mg_set_non_blocking_mode
(
nc
->
sock
);
err
=
0
;
#endif
mg_connect_done
(
nc
,
err
);
}
return
;
}
...
...
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