You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by cl...@apache.org on 2021/12/18 00:50:31 UTC

[qpid-proton] branch main updated: PROTON-2519: epoll proactor - clarify unpolled work and move assertion outside loop repeated with EINTR

This is an automated email from the ASF dual-hosted git repository.

cliffjansen pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git


The following commit(s) were added to refs/heads/main by this push:
     new c8bcd4a  PROTON-2519: epoll proactor - clarify unpolled work and move assertion outside loop repeated with EINTR
c8bcd4a is described below

commit c8bcd4a0991607851cea2c611c550a59db1f47b6
Author: Cliff Jansen <cl...@apache.org>
AuthorDate: Fri Dec 17 12:42:58 2021 -0800

    PROTON-2519: epoll proactor - clarify unpolled work and move assertion outside loop repeated with EINTR
---
 c/src/proactor/epoll.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/c/src/proactor/epoll.c b/c/src/proactor/epoll.c
index 6207267..2f491ca 100644
--- a/c/src/proactor/epoll.c
+++ b/c/src/proactor/epoll.c
@@ -2471,9 +2471,11 @@ static pn_event_batch_t *next_event_batch(pn_proactor_t* p, bool can_block) {
 // Call with sched lock.  Return true if !can_block and no new events to process.
 static bool poller_do_epoll(struct pn_proactor_t* p, tslot_t *ts, bool can_block) {
   // As poller with lots to do, be mindful of hogging the sched lock.  Release when making kernel calls.
+  assert(!p->resched_cutoff);
+  assert(!p->sched_ready_first);
   int n_events;
   task_t *tsk;
-  assert(!p->resched_cutoff);
+  bool unpolled_work = false;
 
   while (true) {
     assert(p->n_runnables == 0);
@@ -2484,13 +2486,15 @@ static bool poller_do_epoll(struct pn_proactor_t* p, tslot_t *ts, bool can_block
     p->last_earmark = NULL;
 
     bool unfinished_earmarks = p->earmark_count > 0;
-    bool epoll_immediate = p->resched_first || unfinished_earmarks || !can_block;
-    assert(!p->sched_ready_first);
+    if (unfinished_earmarks || p->resched_first)
+      unpolled_work = true;
+    bool epoll_immediate = unpolled_work || !can_block;
 
     // Determine if notify_poller() can be avoided.
     if (!epoll_immediate) {
       lock(&p->eventfd_mutex);
       if (p->ready_list_first) {
+        unpolled_work = true;
         epoll_immediate = true;
       } else {
         // Poller may sleep.  Enable eventfd wakeup.
@@ -2508,7 +2512,6 @@ static bool poller_do_epoll(struct pn_proactor_t* p, tslot_t *ts, bool can_block
     lock(&p->sched_mutex);
     p->poller_suspended = false;
 
-    bool unpolled_work = false;
     if (p->resched_first) {
       // Defer future resched tasks until next do_epoll()
       p->resched_cutoff = p->resched_last;

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org