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
31323b01
Commit
31323b01
authored
Dec 07, 2015
by
Sergey Lyubka
Committed by
rojer
Dec 08, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce MG_EV_TIMER event
PUBLISHED_FROM=2e90ee87eda8bc742e427671bb9df1ce0cd8bc25
parent
3a138ecc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
0 deletions
+20
-0
mongoose.c
mongoose.c
+15
-0
mongoose.h
mongoose.h
+5
-0
No files found.
mongoose.c
View file @
31323b01
...
...
@@ -1891,6 +1891,20 @@ MG_INTERNAL void mg_call(struct mg_connection *nc,
(
int
)
nc
->
recv_mbuf
.
len
,
(
int
)
nc
->
send_mbuf
.
len
));
}
void
mg_if_timer
(
struct
mg_connection
*
c
,
time_t
now
)
{
if
(
c
->
ev_timer_time
>
0
&&
now
>=
c
->
ev_timer_time
)
{
double
dnow
=
now
,
old_value
=
c
->
ev_timer_time
;
mg_call
(
c
,
NULL
,
MG_EV_TIMER
,
&
dnow
);
/*
* To prevent timer firing all the time, reset the timer after delivery.
* However, in case user sets it to new value, do not reset.
*/
if
(
c
->
ev_timer_time
==
old_value
)
{
c
->
ev_timer_time
=
0
;
}
}
}
void
mg_if_poll
(
struct
mg_connection
*
nc
,
time_t
now
)
{
mg_call
(
nc
,
NULL
,
MG_EV_POLL
,
&
now
);
}
...
...
@@ -3115,6 +3129,7 @@ void mg_mgr_handle_conn(struct mg_connection *nc, int fd_flags, time_t now) {
if
(
!
(
fd_flags
&
(
_MG_F_FD_CAN_READ
|
_MG_F_FD_CAN_WRITE
)))
{
mg_if_poll
(
nc
,
now
);
}
mg_if_timer
(
nc
,
now
);
DBG
((
"%p after fd=%d nc_flags=%lu rmbl=%d smbl=%d"
,
nc
,
nc
->
sock
,
nc
->
flags
,
(
int
)
nc
->
recv_mbuf
.
len
,
(
int
)
nc
->
send_mbuf
.
len
));
...
...
mongoose.h
View file @
31323b01
...
...
@@ -698,6 +698,7 @@ typedef void (*mg_event_handler_t)(struct mg_connection *, int ev, void *);
#define MG_EV_RECV 3
/* Data has benn received. int *num_bytes */
#define MG_EV_SEND 4
/* Data has been written to a socket. int *num_bytes */
#define MG_EV_CLOSE 5
/* Connection is closed. NULL */
#define MG_EV_TIMER 6
/* now >= conn->ev_timer_time. double * */
/*
* Mongoose event manager.
...
...
@@ -730,6 +731,7 @@ struct mg_connection {
SSL
*
ssl
;
SSL_CTX
*
ssl_ctx
;
time_t
last_io_time
;
/* Timestamp of the last socket IO */
double
ev_timer_time
;
/* Timestamp of the future MG_EV_TIMER */
mg_event_handler_t
proto_handler
;
/* Protocol-specific event handler */
void
*
proto_data
;
/* Protocol-specific data */
mg_event_handler_t
handler
;
/* Event handler function */
...
...
@@ -1116,6 +1118,9 @@ void mg_if_recved(struct mg_connection *nc, size_t len);
/* Deliver a POLL event to the connection. */
void
mg_if_poll
(
struct
mg_connection
*
nc
,
time_t
now
);
/* Deliver a TIMER event to the connection. */
void
mg_if_timer
(
struct
mg_connection
*
c
,
time_t
now
);
/* Perform interface-related cleanup on connection before destruction. */
void
mg_if_destroy_conn
(
struct
mg_connection
*
nc
);
...
...
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