Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
6078a7d3
Commit
6078a7d3
authored
9 years ago
by
Craig Tiller
Browse files
Options
Downloads
Patches
Plain Diff
Add commentary
parent
d49e3a1e
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/core/iomgr/pollset_posix.c
+25
-4
25 additions, 4 deletions
src/core/iomgr/pollset_posix.c
with
25 additions
and
4 deletions
src/core/iomgr/pollset_posix.c
+
25
−
4
View file @
6078a7d3
...
@@ -228,31 +228,44 @@ void grpc_pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
...
@@ -228,31 +228,44 @@ void grpc_pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
int
added_worker
=
0
;
int
added_worker
=
0
;
int
locked
=
1
;
int
locked
=
1
;
int
queued_work
=
0
;
int
queued_work
=
0
;
int
keep_polling
=
0
;
/* this must happen before we (potentially) drop pollset->mu */
/* this must happen before we (potentially) drop pollset->mu */
worker
->
next
=
worker
->
prev
=
NULL
;
worker
->
next
=
worker
->
prev
=
NULL
;
worker
->
reevaluate_polling_on_wakeup
=
0
;
worker
->
reevaluate_polling_on_wakeup
=
0
;
/* TODO(ctiller): pool these */
/* TODO(ctiller): pool these */
grpc_wakeup_fd_init
(
&
worker
->
wakeup_fd
);
grpc_wakeup_fd_init
(
&
worker
->
wakeup_fd
);
/* If there's work waiting for the pollset to be idle, and the
pollset is idle, then do that work */
if
(
!
grpc_pollset_has_workers
(
pollset
)
&&
if
(
!
grpc_pollset_has_workers
(
pollset
)
&&
!
grpc_closure_list_empty
(
pollset
->
idle_jobs
))
{
!
grpc_closure_list_empty
(
pollset
->
idle_jobs
))
{
grpc_exec_ctx_enqueue_list
(
exec_ctx
,
&
pollset
->
idle_jobs
);
grpc_exec_ctx_enqueue_list
(
exec_ctx
,
&
pollset
->
idle_jobs
);
goto
done
;
goto
done
;
}
}
/* Check alarms - these are a global resource so we just ping
each time through on every pollset.
May update deadline to ensure timely wakeups.
TODO(ctiller): can this work be localized? */
if
(
grpc_alarm_check
(
exec_ctx
,
now
,
&
deadline
))
{
if
(
grpc_alarm_check
(
exec_ctx
,
now
,
&
deadline
))
{
gpr_mu_unlock
(
&
pollset
->
mu
);
gpr_mu_unlock
(
&
pollset
->
mu
);
locked
=
0
;
locked
=
0
;
goto
done
;
goto
done
;
}
}
/* If we're shutting down then we don't execute any extended work */
if
(
pollset
->
shutting_down
)
{
if
(
pollset
->
shutting_down
)
{
goto
done
;
goto
done
;
}
}
/* Give do_promote priority so we don't starve it out */
if
(
pollset
->
in_flight_cbs
)
{
if
(
pollset
->
in_flight_cbs
)
{
/* Give do_promote priority so we don't starve it out */
gpr_mu_unlock
(
&
pollset
->
mu
);
gpr_mu_unlock
(
&
pollset
->
mu
);
locked
=
0
;
locked
=
0
;
goto
done
;
goto
done
;
}
}
for
(;;)
{
/* Start polling, and keep doing so while we're being asked to
re-evaluate our pollers (this allows poll() based pollers to
ensure they don't miss wakeups) */
keep_polling
=
1
;
while
(
keep_polling
)
{
keep_polling
=
0
;
if
(
!
pollset
->
kicked_without_pollers
)
{
if
(
!
pollset
->
kicked_without_pollers
)
{
if
(
!
added_worker
)
{
if
(
!
added_worker
)
{
push_front_worker
(
pollset
,
worker
);
push_front_worker
(
pollset
,
worker
);
...
@@ -268,21 +281,29 @@ void grpc_pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
...
@@ -268,21 +281,29 @@ void grpc_pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
}
else
{
}
else
{
pollset
->
kicked_without_pollers
=
0
;
pollset
->
kicked_without_pollers
=
0
;
}
}
/* Finished execution - start cleaning up.
Note that we may arrive here from outside the enclosing while() loop.
In that case we won't loop though as we haven't added worker to the
worker list, which means nobody could ask us to re-evaluate polling). */
done:
done:
if
(
!
locked
)
{
if
(
!
locked
)
{
queued_work
|=
grpc_exec_ctx_flush
(
exec_ctx
);
queued_work
|=
grpc_exec_ctx_flush
(
exec_ctx
);
gpr_mu_lock
(
&
pollset
->
mu
);
gpr_mu_lock
(
&
pollset
->
mu
);
locked
=
1
;
locked
=
1
;
}
}
/* If we're forced to re-evaluate polling (via grpc_pollset_kick with
GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP) then we land here and force
a loop */
if
(
worker
->
reevaluate_polling_on_wakeup
)
{
if
(
worker
->
reevaluate_polling_on_wakeup
)
{
worker
->
reevaluate_polling_on_wakeup
=
0
;
worker
->
reevaluate_polling_on_wakeup
=
0
;
pollset
->
kicked_without_pollers
=
0
;
pollset
->
kicked_without_pollers
=
0
;
if
(
queued_work
)
{
if
(
queued_work
)
{
/* If there's queued work on the list, then set the deadline to be
immediate so we get back out of the polling loop quickly */
deadline
=
gpr_inf_past
(
GPR_CLOCK_MONOTONIC
);
deadline
=
gpr_inf_past
(
GPR_CLOCK_MONOTONIC
);
}
}
continue
;
keep_polling
=
1
;
}
}
break
;
}
}
if
(
added_worker
)
{
if
(
added_worker
)
{
remove_worker
(
pollset
,
worker
);
remove_worker
(
pollset
,
worker
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment