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
400084ea
Commit
400084ea
authored
Jan 17, 2014
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
read_from_client -> read_from_socket
parent
82ad9a07
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
39 deletions
+35
-39
mongoose.c
mongoose.c
+35
-39
No files found.
mongoose.c
View file @
400084ea
...
...
@@ -1923,7 +1923,7 @@ static void call_uri_handler(struct connection *conn) {
}
}
static
void
write_to_
clien
t
(
struct
connection
*
conn
)
{
static
void
write_to_
socke
t
(
struct
connection
*
conn
)
{
struct
iobuf
*
io
=
&
conn
->
remote_iobuf
;
int
n
=
conn
->
ssl
==
NULL
?
send
(
conn
->
client_sock
,
io
->
buf
,
io
->
len
,
0
)
:
#ifdef USE_SSL
...
...
@@ -3475,30 +3475,43 @@ static void process_request(struct connection *conn) {
#endif
}
static
void
read_from_
clien
t
(
struct
connection
*
conn
)
{
static
void
read_from_
socke
t
(
struct
connection
*
conn
)
{
char
buf
[
IOBUF_SIZE
];
int
n
=
0
;
if
(
conn
->
ssl
!=
NULL
)
{
int
ok
,
n
=
0
;
socklen_t
len
=
sizeof
(
ok
);
if
(
conn
->
endpoint_type
==
EP_CLIENT
)
{
conn
->
mg_conn
.
wsbits
=
1
;
if
(
!
(
conn
->
flags
&
CONN_CONNECTED
)
&&
getsockopt
(
conn
->
client_sock
,
SOL_SOCKET
,
SO_ERROR
,
(
char
*
)
&
ok
,
&
len
)
<
0
)
{
conn
->
mg_conn
.
wsbits
=
0
;
}
conn
->
handler
(
&
conn
->
mg_conn
);
conn
->
flags
|=
CONN_CLOSE
|
CONN_CONNECTED
;
}
else
{
if
(
conn
->
ssl
!=
NULL
)
{
#ifdef USE_SSL
if
(
conn
->
flags
&
CONN_SSL_HANDS_SHAKEN
)
{
n
=
SSL_read
(
conn
->
ssl
,
buf
,
sizeof
(
buf
));
}
else
{
if
(
SSL_accept
(
conn
->
ssl
)
==
1
)
{
conn
->
flags
|=
CONN_SSL_HANDS_SHAKEN
;
if
(
conn
->
flags
&
CONN_SSL_HANDS_SHAKEN
)
{
n
=
SSL_read
(
conn
->
ssl
,
buf
,
sizeof
(
buf
));
}
else
{
if
(
SSL_accept
(
conn
->
ssl
)
==
1
)
{
conn
->
flags
|=
CONN_SSL_HANDS_SHAKEN
;
}
return
;
}
return
;
}
#endif
}
else
{
n
=
recv
(
conn
->
client_sock
,
buf
,
sizeof
(
buf
),
0
);
}
}
else
{
n
=
recv
(
conn
->
client_sock
,
buf
,
sizeof
(
buf
),
0
);
}
DBG
((
"%p %d"
,
conn
,
n
));
if
(
is_error
(
n
))
{
conn
->
flags
|=
CONN_CLOSE
;
}
else
if
(
n
>
0
)
{
spool
(
&
conn
->
local_iobuf
,
buf
,
n
);
process_request
(
conn
);
DBG
((
"%p %d"
,
conn
,
n
));
if
(
is_error
(
n
))
{
conn
->
flags
|=
CONN_CLOSE
;
}
else
if
(
n
>
0
)
{
spool
(
&
conn
->
local_iobuf
,
buf
,
n
);
process_request
(
conn
);
}
}
}
...
...
@@ -3541,19 +3554,6 @@ int mg_connect(struct mg_server *server, const char *host,
return
1
;
}
static
void
read_from_server
(
struct
connection
*
conn
)
{
sock_t
ok
,
sock
=
conn
->
client_sock
;
socklen_t
len
=
sizeof
(
ok
);
conn
->
mg_conn
.
wsbits
=
1
;
if
(
!
(
conn
->
flags
&
CONN_CONNECTED
)
&&
getsockopt
(
sock
,
SOL_SOCKET
,
SO_ERROR
,
(
char
*
)
&
ok
,
&
len
)
<
0
)
{
conn
->
mg_conn
.
wsbits
=
0
;
}
conn
->
handler
(
&
conn
->
mg_conn
);
conn
->
flags
|=
CONN_CLOSE
|
CONN_CONNECTED
;
}
#ifndef NO_LOGGING
static
void
log_header
(
const
struct
mg_connection
*
conn
,
const
char
*
header
,
FILE
*
fp
)
{
...
...
@@ -3722,11 +3722,7 @@ unsigned int mg_poll_server(struct mg_server *server, int milliseconds) {
conn
=
LINKED_LIST_ENTRY
(
lp
,
struct
connection
,
link
);
if
(
FD_ISSET
(
conn
->
client_sock
,
&
read_set
))
{
conn
->
last_activity_time
=
current_time
;
if
(
conn
->
endpoint_type
==
EP_CLIENT
)
{
read_from_server
(
conn
);
}
else
{
read_from_client
(
conn
);
}
read_from_socket
(
conn
);
}
#ifndef NO_CGI
if
(
conn
->
endpoint_type
==
EP_CGI
&&
...
...
@@ -3737,7 +3733,7 @@ unsigned int mg_poll_server(struct mg_server *server, int milliseconds) {
if
(
FD_ISSET
(
conn
->
client_sock
,
&
write_set
)
&&
!
(
conn
->
flags
&
CONN_BUFFER
))
{
conn
->
last_activity_time
=
current_time
;
write_to_
clien
t
(
conn
);
write_to_
socke
t
(
conn
);
}
}
}
...
...
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