Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
timeout.c
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
timeout.c
Commits
269e8df4
Commit
269e8df4
authored
Feb 24, 2016
by
William Ahern
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'optional_intervals'
parents
1aa993e3
ae78c6a9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
7 deletions
+15
-7
timeout.c
timeout.c
+11
-7
timeout.h
timeout.h
+4
-0
No files found.
timeout.c
View file @
269e8df4
...
@@ -265,8 +265,8 @@ static void timeouts_reset(struct timeouts *T) {
...
@@ -265,8 +265,8 @@ static void timeouts_reset(struct timeouts *T) {
TAILQ_CONCAT
(
&
reset
,
&
T
->
expired
,
tqe
);
TAILQ_CONCAT
(
&
reset
,
&
T
->
expired
,
tqe
);
TAILQ_FOREACH
(
to
,
&
reset
,
tqe
)
{
TAILQ_FOREACH
(
to
,
&
reset
,
tqe
)
{
TO_SET_TIMEOUTS
(
to
,
NULL
);
to
->
pending
=
NULL
;
to
->
pending
=
NULL
;
TO_SET_TIMEOUTS
(
to
,
NULL
);
}
}
}
/* timeouts_reset() */
}
/* timeouts_reset() */
...
@@ -353,6 +353,7 @@ static void timeouts_sched(struct timeouts *T, struct timeout *to, timeout_t exp
...
@@ -353,6 +353,7 @@ static void timeouts_sched(struct timeouts *T, struct timeout *to, timeout_t exp
}
/* timeouts_sched() */
}
/* timeouts_sched() */
#ifndef TIMEOUT_DISABLE_INTERVALS
static
void
timeouts_readd
(
struct
timeouts
*
T
,
struct
timeout
*
to
)
{
static
void
timeouts_readd
(
struct
timeouts
*
T
,
struct
timeout
*
to
)
{
to
->
expires
+=
to
->
interval
;
to
->
expires
+=
to
->
interval
;
...
@@ -373,11 +374,14 @@ static void timeouts_readd(struct timeouts *T, struct timeout *to) {
...
@@ -373,11 +374,14 @@ static void timeouts_readd(struct timeouts *T, struct timeout *to) {
timeouts_sched
(
T
,
to
,
to
->
expires
);
timeouts_sched
(
T
,
to
,
to
->
expires
);
}
/* timeouts_readd() */
}
/* timeouts_readd() */
#endif
TIMEOUT_PUBLIC
void
timeouts_add
(
struct
timeouts
*
T
,
struct
timeout
*
to
,
timeout_t
timeout
)
{
TIMEOUT_PUBLIC
void
timeouts_add
(
struct
timeouts
*
T
,
struct
timeout
*
to
,
timeout_t
timeout
)
{
#ifndef TIMEOUT_DISABLE_INTERVALS
if
(
to
->
flags
&
TIMEOUT_INT
)
if
(
to
->
flags
&
TIMEOUT_INT
)
to
->
interval
=
MAX
(
1
,
timeout
);
to
->
interval
=
MAX
(
1
,
timeout
);
#endif
if
(
to
->
flags
&
TIMEOUT_ABS
)
if
(
to
->
flags
&
TIMEOUT_ABS
)
timeouts_sched
(
T
,
to
,
timeout
);
timeouts_sched
(
T
,
to
,
timeout
);
...
@@ -453,7 +457,7 @@ TIMEOUT_PUBLIC void timeouts_update(struct timeouts *T, abstime_t curtime) {
...
@@ -453,7 +457,7 @@ TIMEOUT_PUBLIC void timeouts_update(struct timeouts *T, abstime_t curtime) {
struct
timeout
*
to
=
TAILQ_FIRST
(
&
todo
);
struct
timeout
*
to
=
TAILQ_FIRST
(
&
todo
);
TAILQ_REMOVE
(
&
todo
,
to
,
tqe
);
TAILQ_REMOVE
(
&
todo
,
to
,
tqe
);
to
->
pending
=
0
;
to
->
pending
=
NULL
;
timeouts_sched
(
T
,
to
,
to
->
expires
);
timeouts_sched
(
T
,
to
,
to
->
expires
);
}
}
...
@@ -547,13 +551,13 @@ TIMEOUT_PUBLIC struct timeout *timeouts_get(struct timeouts *T) {
...
@@ -547,13 +551,13 @@ TIMEOUT_PUBLIC struct timeout *timeouts_get(struct timeouts *T) {
struct
timeout
*
to
=
TAILQ_FIRST
(
&
T
->
expired
);
struct
timeout
*
to
=
TAILQ_FIRST
(
&
T
->
expired
);
TAILQ_REMOVE
(
&
T
->
expired
,
to
,
tqe
);
TAILQ_REMOVE
(
&
T
->
expired
,
to
,
tqe
);
to
->
pending
=
0
;
to
->
pending
=
NULL
;
TO_SET_TIMEOUTS
(
to
,
NULL
);
if
((
to
->
flags
&
TIMEOUT_INT
)
&&
to
->
interval
>
0
)
{
#ifndef TIMEOUT_DISABLE_INTERVALS
if
((
to
->
flags
&
TIMEOUT_INT
)
&&
to
->
interval
>
0
)
timeouts_readd
(
T
,
to
);
timeouts_readd
(
T
,
to
);
}
else
{
#endif
TO_SET_TIMEOUTS
(
to
,
NULL
);
}
return
to
;
return
to
;
}
else
{
}
else
{
...
...
timeout.h
View file @
269e8df4
...
@@ -100,7 +100,9 @@ struct timeout_cb {
...
@@ -100,7 +100,9 @@ struct timeout_cb {
*
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef TIMEOUT_DISABLE_INTERVALS
#define TIMEOUT_INT 0x01
/* interval (repeating) timeout */
#define TIMEOUT_INT 0x01
/* interval (repeating) timeout */
#endif
#define TIMEOUT_ABS 0x02
/* treat timeout values as absolute */
#define TIMEOUT_ABS 0x02
/* treat timeout values as absolute */
#define TIMEOUT_INITIALIZER(flags) { (flags) }
#define TIMEOUT_INITIALIZER(flags) { (flags) }
...
@@ -113,8 +115,10 @@ struct timeout_cb {
...
@@ -113,8 +115,10 @@ struct timeout_cb {
struct
timeout
{
struct
timeout
{
int
flags
;
int
flags
;
#ifndef TIMEOUT_DISABLE_INTERVALS
timeout_t
interval
;
timeout_t
interval
;
/* timeout interval if periodic */
/* timeout interval if periodic */
#endif
timeout_t
expires
;
timeout_t
expires
;
/* absolute expiration time */
/* absolute expiration time */
...
...
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