You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ic...@apache.org on 2022/03/23 09:15:31 UTC

svn commit: r1899149 - in /httpd/httpd/trunk/modules/http2: h2_mplx.c h2_mplx.h h2_workers.c

Author: icing
Date: Wed Mar 23 09:15:30 2022
New Revision: 1899149

URL: http://svn.apache.org/viewvc?rev=1899149&view=rev
Log:
  *) mod_http2: removed extra h2_mplx_worker_c2_done() arg
     to retrive another c2 for processing. Just added
     complexity without measurable benefits.


Modified:
    httpd/httpd/trunk/modules/http2/h2_mplx.c
    httpd/httpd/trunk/modules/http2/h2_mplx.h
    httpd/httpd/trunk/modules/http2/h2_workers.c

Modified: httpd/httpd/trunk/modules/http2/h2_mplx.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http2/h2_mplx.c?rev=1899149&r1=1899148&r2=1899149&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http2/h2_mplx.c (original)
+++ httpd/httpd/trunk/modules/http2/h2_mplx.c Wed Mar 23 09:15:30 2022
@@ -480,7 +480,6 @@ void h2_mplx_c1_destroy(h2_mplx *m)
             h2_ihash_iter(m->shold, m_report_stream_iter, m);
         }
     }
-    m->join_wait = NULL;
 
     /* 4. With all workers done, all streams should be in spurge */
     ap_assert(m->processing_count == 0);
@@ -614,20 +613,6 @@ apr_status_t h2_mplx_c1_reprioritize(h2_
     return status;
 }
 
-static void ms_register_if_needed(h2_mplx *m, int from_master)
-{
-    if (!m->aborted && !m->is_registered && !h2_iq_empty(m->q)) {
-        apr_status_t status = h2_workers_register(m->workers, m); 
-        if (status == APR_SUCCESS) {
-            m->is_registered = 1;
-        }
-        else if (from_master) {
-            ap_log_cerror(APLOG_MARK, APLOG_ERR, status, m->c1, APLOGNO(10021)
-                          "h2_mplx(%ld): register at workers", m->id);
-        }
-    }
-}
-
 static apr_status_t c1_process_stream(h2_mplx *m,
                                       h2_stream *stream,
                                       h2_stream_pri_cmp_fn *cmp,
@@ -670,17 +655,17 @@ cleanup:
     return rv;
 }
 
-apr_status_t h2_mplx_c1_process(h2_mplx *m,
-                                h2_iqueue *ready_to_process,
-                                h2_stream_get_fn *get_stream,
-                                h2_stream_pri_cmp_fn *stream_pri_cmp,
-                                h2_session *session,
-                                int *pstream_count)
+void h2_mplx_c1_process(h2_mplx *m,
+                        h2_iqueue *ready_to_process,
+                        h2_stream_get_fn *get_stream,
+                        h2_stream_pri_cmp_fn *stream_pri_cmp,
+                        h2_session *session,
+                        int *pstream_count)
 {
-    apr_status_t rv = APR_SUCCESS;
+    apr_status_t rv;
     int sid;
 
-    H2_MPLX_ENTER(m);
+    H2_MPLX_ENTER_ALWAYS(m);
 
     while ((sid = h2_iq_shift(ready_to_process)) > 0) {
         h2_stream *stream = get_stream(session, sid);
@@ -696,8 +681,18 @@ apr_status_t h2_mplx_c1_process(h2_mplx
                           "h2_stream(%ld-%d): not found to process", m->id, sid);
         }
     }
-    ms_register_if_needed(m, 1);
+    if (!m->is_registered && !h2_iq_empty(m->q)) {
+        rv = h2_workers_register(m->workers, m);
+        if (rv == APR_SUCCESS) {
+            m->is_registered = 1;
+        }
+        else {
+            ap_log_cerror(APLOG_MARK, APLOG_ERR, rv, m->c1, APLOGNO(10021)
+                          "h2_mplx(%ld): register at workers", m->id);
+        }
+    }
     *pstream_count = (int)h2_ihash_count(m->streams);
+
 #if APR_POOL_DEBUG
     do {
         apr_size_t mem_g, mem_m, mem_s, mem_w, mem_c1;
@@ -715,7 +710,6 @@ apr_status_t h2_mplx_c1_process(h2_mplx
 #endif
 
     H2_MPLX_LEAVE(m);
-    return rv;
 }
 
 apr_status_t h2_mplx_c1_fwd_input(h2_mplx *m, struct h2_iqueue *input_pending,
@@ -884,11 +878,9 @@ apr_status_t h2_mplx_worker_pop_c2(h2_mp
     *out_c = NULL;
     ap_assert(m);
     ap_assert(m->lock);
-    
-    if (APR_SUCCESS != (rv = apr_thread_mutex_lock(m->lock))) {
-        return rv;
-    }
-    
+
+    H2_MPLX_ENTER(m);
+
     if (m->aborted) {
         rv = APR_EOF;
     }
@@ -967,29 +959,18 @@ static void s_c2_done(h2_mplx *m, conn_r
     }
 }
 
-void h2_mplx_worker_c2_done(conn_rec *c2, conn_rec **out_c2)
+void h2_mplx_worker_c2_done(conn_rec *c2)
 {
     h2_conn_ctx_t *conn_ctx = h2_conn_ctx_get(c2);
-    h2_mplx *m = conn_ctx? conn_ctx->mplx : NULL;
-
-    if (!m) {
-        if (out_c2) *out_c2 = NULL;
-        return;
-    }
+    h2_mplx *m;
 
+    AP_DEBUG_ASSERT(conn_ctx);
+    m = conn_ctx->mplx;
     H2_MPLX_ENTER_ALWAYS(m);
 
     --m->processing_count;
     s_c2_done(m, c2, conn_ctx);
-
-    if (m->join_wait) {
-        apr_thread_cond_signal(m->join_wait);
-    }
-    if (out_c2) {
-        /* caller wants another connection to process */
-        *out_c2 = s_next_c2(m);
-    }
-    ms_register_if_needed(m, 0);
+    apr_thread_cond_signal(m->join_wait);
 
     H2_MPLX_LEAVE(m);
 }

Modified: httpd/httpd/trunk/modules/http2/h2_mplx.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http2/h2_mplx.h?rev=1899149&r1=1899148&r2=1899149&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http2/h2_mplx.h (original)
+++ httpd/httpd/trunk/modules/http2/h2_mplx.h Wed Mar 23 09:15:30 2022
@@ -146,12 +146,12 @@ int h2_mplx_c1_stream_is_running(h2_mplx
  * @param cmp the stream priority compare function
  * @param pstream_count on return the number of streams active in mplx
  */
-apr_status_t h2_mplx_c1_process(h2_mplx *m,
-                                struct h2_iqueue *read_to_process,
-                                h2_stream_get_fn *get_stream,
-                                h2_stream_pri_cmp_fn *cmp,
-                                struct h2_session *session,
-                                int *pstream_count);
+void h2_mplx_c1_process(h2_mplx *m,
+                        struct h2_iqueue *read_to_process,
+                        h2_stream_get_fn *get_stream,
+                        h2_stream_pri_cmp_fn *cmp,
+                        struct h2_session *session,
+                        int *pstream_count);
 
 apr_status_t h2_mplx_c1_fwd_input(h2_mplx *m, struct h2_iqueue *input_pending,
                                   h2_stream_get_fn *get_stream,
@@ -213,12 +213,8 @@ apr_status_t h2_mplx_worker_pop_c2(h2_mp
 
 /**
  * A h2 worker reports a secondary connection processing done.
- * If it is will to do more work for this mplx (this c1 connection),
- * it provides `out_c`. Otherwise it passes NULL.
  * @param c2 the secondary connection finished processing
- * @param out_c2 NULL or a pointer where to reveive the next
- *               secondary connection to process.
  */
-void h2_mplx_worker_c2_done(conn_rec *c2, conn_rec **out_c2);
+void h2_mplx_worker_c2_done(conn_rec *c2);
 
 #endif /* defined(__mod_h2__h2_mplx__) */

Modified: httpd/httpd/trunk/modules/http2/h2_workers.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http2/h2_workers.c?rev=1899149&r1=1899148&r2=1899149&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http2/h2_workers.c (original)
+++ httpd/httpd/trunk/modules/http2/h2_workers.c Wed Mar 23 09:15:30 2022
@@ -255,18 +255,10 @@ static void* APR_THREAD_FUNC slot_run(ap
     
     /* Get the next c2 from mplx to process. */
     while (get_next(slot)) {
-        do {
-            ap_assert(slot->connection != NULL);
-            h2_c2_process(slot->connection, thread, slot->id);
-            if (apr_atomic_read32(&slot->workers->aborted) == 0 &&
-                apr_atomic_read32(&slot->workers->worker_count) < slot->workers->max_workers) {
-                h2_mplx_worker_c2_done(slot->connection, &slot->connection);
-            }
-            else {
-                h2_mplx_worker_c2_done(slot->connection, NULL);
-                slot->connection = NULL;
-            }
-        } while (slot->connection);
+        ap_assert(slot->connection != NULL);
+        h2_c2_process(slot->connection, thread, slot->id);
+        h2_mplx_worker_c2_done(slot->connection);
+        slot->connection = NULL;
     }
 
     if (apr_atomic_read32(&slot->timed_out) == 0) {