Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
4949a717
Commit
4949a717
authored
Sep 20, 2004
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved timeout processing to a separate function.
parent
67c8cb28
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
39 deletions
+45
-39
fd.c
server/fd.c
+45
-39
No files found.
server/fd.c
View file @
4949a717
...
@@ -288,61 +288,67 @@ static void remove_poll_user( struct fd *fd, int user )
...
@@ -288,61 +288,67 @@ static void remove_poll_user( struct fd *fd, int user )
active_users
--
;
active_users
--
;
}
}
/* process pending timeouts and return the time until the next timeout, in milliseconds */
/* server main poll() loop */
static
int
get_next_timeout
(
void
)
void
main_loop
(
void
)
{
{
int
ret
;
if
(
!
list_empty
(
&
timeout_list
))
while
(
active_users
)
{
{
long
diff
=
-
1
;
struct
list
expired_list
,
*
ptr
;
if
(
!
list_empty
(
&
timeout_list
))
struct
timeval
now
;
{
struct
list
expired_list
,
*
ptr
;
struct
timeval
now
;
gettimeofday
(
&
now
,
NULL
);
/* first remove all expired timers from the list */
gettimeofday
(
&
now
,
NULL
);
list_init
(
&
expired_list
);
/* first remove all expired timers from the list */
while
((
ptr
=
list_head
(
&
timeout_list
))
!=
NULL
)
{
struct
timeout_user
*
timeout
=
LIST_ENTRY
(
ptr
,
struct
timeout_user
,
entry
);
if
(
!
time_before
(
&
now
,
&
timeout
->
when
))
list_init
(
&
expired_list
);
{
while
((
ptr
=
list_head
(
&
timeout_list
))
!=
NULL
)
list_remove
(
&
timeout
->
entry
);
{
list_add_tail
(
&
expired_list
,
&
timeout
->
entry
);
struct
timeout_user
*
timeout
=
LIST_ENTRY
(
ptr
,
struct
timeout_user
,
entry
);
}
else
break
;
}
/* now call the callback for all the removed timers */
while
((
ptr
=
list_head
(
&
expired_list
))
!=
NULL
)
if
(
!
time_before
(
&
now
,
&
timeout
->
when
)
)
{
{
struct
timeout_user
*
timeout
=
LIST_ENTRY
(
ptr
,
struct
timeout_user
,
entry
);
list_remove
(
&
timeout
->
entry
);
list_remove
(
&
timeout
->
entry
);
timeout
->
callback
(
timeout
->
private
);
list_add_tail
(
&
expired_list
,
&
timeout
->
entry
);
free
(
timeout
);
}
}
else
break
;
}
if
(
!
active_users
)
break
;
/* last user removed by a timeout
*/
/* now call the callback for all the removed timers
*/
if
((
ptr
=
list_head
(
&
timeout_list
))
!=
NULL
)
while
((
ptr
=
list_head
(
&
expired_list
))
!=
NULL
)
{
{
struct
timeout_user
*
timeout
=
LIST_ENTRY
(
ptr
,
struct
timeout_user
,
entry
);
struct
timeout_user
*
timeout
=
LIST_ENTRY
(
ptr
,
struct
timeout_user
,
entry
);
diff
=
(
timeout
->
when
.
tv_sec
-
now
.
tv_sec
)
*
1000
list_remove
(
&
timeout
->
entry
);
timeout
->
callback
(
timeout
->
private
);
free
(
timeout
);
}
if
((
ptr
=
list_head
(
&
timeout_list
))
!=
NULL
)
{
struct
timeout_user
*
timeout
=
LIST_ENTRY
(
ptr
,
struct
timeout_user
,
entry
);
int
diff
=
(
timeout
->
when
.
tv_sec
-
now
.
tv_sec
)
*
1000
+
(
timeout
->
when
.
tv_usec
-
now
.
tv_usec
)
/
1000
;
+
(
timeout
->
when
.
tv_usec
-
now
.
tv_usec
)
/
1000
;
if
(
diff
<
0
)
diff
=
0
;
if
(
diff
<
0
)
diff
=
0
;
}
return
diff
;
}
}
}
return
-
1
;
/* no pending timeouts */
}
/* server main poll() loop */
void
main_loop
(
void
)
{
int
i
,
ret
,
timeout
;
while
(
active_users
)
{
timeout
=
get_next_timeout
();
if
(
!
active_users
)
break
;
/* last user removed by a timeout */
ret
=
poll
(
pollfd
,
nb_users
,
diff
);
ret
=
poll
(
pollfd
,
nb_users
,
timeout
);
if
(
ret
>
0
)
if
(
ret
>
0
)
{
{
int
i
;
for
(
i
=
0
;
i
<
nb_users
;
i
++
)
for
(
i
=
0
;
i
<
nb_users
;
i
++
)
{
{
if
(
pollfd
[
i
].
revents
)
if
(
pollfd
[
i
].
revents
)
...
...
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