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
870ca615
Commit
870ca615
authored
Jun 09, 2014
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added mg_next()
parent
64b51699
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
4 deletions
+18
-4
mongoose.c
mongoose.c
+17
-4
mongoose.h
mongoose.h
+1
-0
No files found.
mongoose.c
View file @
870ca615
...
...
@@ -222,6 +222,7 @@ int ns_server_poll(struct ns_server *, int milli);
void
ns_server_wakeup
(
struct
ns_server
*
);
void
ns_server_wakeup_ex
(
struct
ns_server
*
,
ns_callback_t
,
void
*
,
size_t
);
void
ns_iterate
(
struct
ns_server
*
,
ns_callback_t
cb
,
void
*
param
);
struct
ns_connection
*
ns_next
(
struct
ns_server
*
,
struct
ns_connection
*
);
struct
ns_connection
*
ns_add_sock
(
struct
ns_server
*
,
sock_t
sock
,
void
*
p
);
int
ns_bind
(
struct
ns_server
*
,
const
char
*
addr
);
...
...
@@ -876,7 +877,7 @@ int ns_server_poll(struct ns_server *server, int milli) {
if
(
server
->
ctl
[
1
]
!=
INVALID_SOCKET
&&
FD_ISSET
(
server
->
ctl
[
1
],
&
read_set
))
{
struct
ctl_msg
ctl_msg
;
int
len
=
recv
(
server
->
ctl
[
1
],
(
char
*
)
&
ctl_msg
,
sizeof
(
ctl_msg
),
0
);
int
len
=
recv
(
server
->
ctl
[
1
],
(
void
*
)
&
ctl_msg
,
sizeof
(
ctl_msg
),
0
);
send
(
server
->
ctl
[
1
],
ctl_msg
.
message
,
1
,
0
);
if
(
len
>=
(
int
)
sizeof
(
ctl_msg
.
callback
)
&&
ctl_msg
.
callback
!=
NULL
)
{
ns_iterate
(
server
,
ctl_msg
.
callback
,
ctl_msg
.
message
);
...
...
@@ -885,7 +886,6 @@ int ns_server_poll(struct ns_server *server, int milli) {
for
(
conn
=
server
->
active_connections
;
conn
!=
NULL
;
conn
=
tmp_conn
)
{
tmp_conn
=
conn
->
next
;
//DBG(("%p LOOP %p", conn, conn->ssl));
if
(
FD_ISSET
(
conn
->
sock
,
&
read_set
))
{
conn
->
last_io_time
=
current_time
;
ns_read_from_socket
(
conn
);
...
...
@@ -979,6 +979,10 @@ struct ns_connection *ns_add_sock(struct ns_server *s, sock_t sock, void *p) {
return
conn
;
}
struct
ns_connection
*
ns_next
(
struct
ns_server
*
s
,
struct
ns_connection
*
conn
)
{
return
conn
==
NULL
?
s
->
active_connections
:
conn
->
next
;
}
void
ns_iterate
(
struct
ns_server
*
server
,
ns_callback_t
cb
,
void
*
param
)
{
struct
ns_connection
*
conn
,
*
tmp_conn
;
...
...
@@ -995,9 +999,9 @@ void ns_server_wakeup_ex(struct ns_server *server, ns_callback_t cb,
len
<
sizeof
(
ctl_msg
.
message
))
{
ctl_msg
.
callback
=
cb
;
memcpy
(
ctl_msg
.
message
,
data
,
len
);
send
(
server
->
ctl
[
0
],
(
char
*
)
&
ctl_msg
,
send
(
server
->
ctl
[
0
],
(
void
*
)
&
ctl_msg
,
offsetof
(
struct
ctl_msg
,
message
)
+
len
,
0
);
recv
(
server
->
ctl
[
0
],
(
char
*
)
&
len
,
1
,
0
);
recv
(
server
->
ctl
[
0
],
(
void
*
)
&
len
,
1
,
0
);
}
}
...
...
@@ -4546,6 +4550,15 @@ static void iter(struct ns_connection *nsconn, enum ns_event ev, void *param) {
}
}
struct
mg_connection
*
mg_next
(
struct
mg_server
*
s
,
struct
mg_connection
*
c
)
{
struct
connection
*
conn
=
MG_CONN_2_CONN
(
c
);
struct
ns_connection
*
nc
=
ns_next
(
&
s
->
ns_server
,
c
==
NULL
?
NULL
:
conn
->
ns_conn
);
return
nc
==
NULL
?
NULL
:
&
((
struct
connection
*
)
nc
->
connection_data
)
->
mg_conn
;
}
// Apply function to all active connections.
void
mg_iterate_over_connections
(
struct
mg_server
*
server
,
mg_handler_t
cb
,
void
*
param
)
{
...
...
mongoose.h
View file @
870ca615
...
...
@@ -93,6 +93,7 @@ const char *mg_get_option(const struct mg_server *server, const char *name);
void
mg_set_listening_socket
(
struct
mg_server
*
,
int
sock
);
int
mg_get_listening_socket
(
struct
mg_server
*
);
void
mg_iterate_over_connections
(
struct
mg_server
*
,
mg_handler_t
,
void
*
);
struct
mg_connection
*
mg_next
(
struct
mg_server
*
,
struct
mg_connection
*
);
void
mg_wakeup_server
(
struct
mg_server
*
);
void
mg_wakeup_server_ex
(
struct
mg_server
*
,
mg_handler_t
,
const
char
*
,
...);
struct
mg_connection
*
mg_connect
(
struct
mg_server
*
,
const
char
*
,
int
,
int
);
...
...
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