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 2020/09/18 17:51:45 UTC

[qpid-proton] branch master updated: PROTON-2277: maintain some extra epoll related state to aid debugging

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 31a5cd2  PROTON-2277: maintain some extra epoll related state to aid debugging
31a5cd2 is described below

commit 31a5cd2e3f162cff25ee2b7b2cf54f4a93fa6aa0
Author: Cliff Jansen <cl...@apache.org>
AuthorDate: Fri Sep 18 10:51:35 2020 -0700

    PROTON-2277: maintain some extra epoll related state to aid debugging
---
 c/src/proactor/epoll-internal.h |  6 ++++++
 c/src/proactor/epoll.c          | 28 ++++++++++++++++++++++++----
 2 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/c/src/proactor/epoll-internal.h b/c/src/proactor/epoll-internal.h
index 78cad14..c0c2b68 100644
--- a/c/src/proactor/epoll-internal.h
+++ b/c/src/proactor/epoll-internal.h
@@ -190,6 +190,8 @@ struct pn_proactor_t {
   int earmark_count;
   bool earmark_drain;
   bool sched_wakes_pending;
+  // For debugging help for core dumps with optimized code.
+  pn_event_type_t current_event_type;
 
   // Mostly read only: after init or once thread_count stabilizes
   pn_collector_t *collector  __attribute__((aligned(64)));
@@ -247,6 +249,10 @@ typedef struct pconnection_t {
   bool io_doublecheck;               /* callbacks made and new IO may have arrived */
   bool sched_timeout;
   char addr_buf[1];
+  // For debugging help for core dumps with optimized code.
+  pn_event_type_t current_event_type;
+  uint32_t process_args;
+  uint32_t process_events;
 } pconnection_t;
 
 /*
diff --git a/c/src/proactor/epoll.c b/c/src/proactor/epoll.c
index 1e693fe..01d9db8 100644
--- a/c/src/proactor/epoll.c
+++ b/c/src/proactor/epoll.c
@@ -1012,7 +1012,10 @@ static pn_event_t *pconnection_batch_next(pn_event_batch_t *batch) {
       }
     }
   }
-  if (e) pc->output_drained = false;
+  if (e) {
+    pc->output_drained = false;
+    pc->current_event_type = pn_event_type(e);
+  }
 
   return e;
 }
@@ -1074,23 +1077,34 @@ static inline void pconnection_rearm(pconnection_t *pc, int wanted_now) {
 /* Only call when context switch is imminent.  Sched lock is highly contested. */
 // Call with both context and sched locks.
 static bool pconnection_sched_sync(pconnection_t *pc, bool *timerfd_fired) {
+  uint32_t sync_events = 0;
+  uint32_t sync_args = 0;
   *timerfd_fired = false;
   if (pc->sched_timeout) {
     *timerfd_fired = true;;
     pc->timer_armed = false;
     pc->sched_timeout = false;
+    sync_args |= (1 << 1);
   }
   if (pc->psocket.sched_io_events) {
     pc->new_events = pc->psocket.sched_io_events;
     pc->psocket.sched_io_events = 0;
     pc->current_arm = 0;  // or outside lock?
+    sync_events = pc->new_events;
   }
   if (pc->context.sched_wake) {
     pc->context.sched_wake = false;
     wake_done(&pc->context);
+    sync_args |= 1;
   }
   pc->context.sched_pending = false;
 
+  if (sync_args || sync_events) {
+    // Only replace if poller has found new work for us.
+    pc->process_args = sync_args;
+    pc->process_events = sync_events;
+  }
+
   // Indicate if there are free proactor threads
   pn_proactor_t *p = pc->context.proactor;
   return p->poller_suspended || p->suspend_list_head;
@@ -1233,7 +1247,10 @@ static pn_event_batch_t *pconnection_process(pconnection_t *pc, uint32_t events,
   bool waking = false;
   bool tick_required = false;
   bool immediate_write = false;
-
+  if (!topup) {
+    pc->process_events = events;
+    pc->process_args = (timeout << 1) | sched_wake;
+  }
   // Don't touch data exclusive to working thread (yet).
   if (timeout) {
     rearm_timer = true;
@@ -2206,8 +2223,11 @@ static pn_event_t *proactor_batch_next(pn_event_batch_t *batch) {
   lock(&p->context.mutex);
   proactor_update_batch(p);
   pn_event_t *e = pn_collector_next(p->collector);
-  if (e && pn_event_type(e) == PN_PROACTOR_TIMEOUT)
-    p->timeout_processed = true;
+  if (e) {
+    p->current_event_type = pn_event_type(e);
+    if (p->current_event_type == PN_PROACTOR_TIMEOUT)
+      p->timeout_processed = true;
+  }
   unlock(&p->context.mutex);
   return pni_log_event(p, e);
 }


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