On Wed, Sep 12, 2018 at 5:53 PM Eric Covener <cove...@gmail.com> wrote: > > Forking from the Cool Stuff thread. > > Have you noticed that the wstunnell stuff makes the suspended count in > the MPM grow? There is no API for us to tell the MPM that when we get > the socket-activity callback that we are "resuming" something. > > (going from vague recollection)
It seems that we increment it once when the handler returns SUSPENDED, and decrement it once per connection too in proxy_wstunnel_finish(). However, looks like there is unnecessary churn proxy_wstunnel_finish(), including a double close since the MPM will also finally close the client connection. How about something like the attached? Regards, Yann.
Index: modules/proxy/mod_proxy_wstunnel.c =================================================================== --- modules/proxy/mod_proxy_wstunnel.c (revision 1840709) +++ modules/proxy/mod_proxy_wstunnel.c (working copy) @@ -155,15 +155,14 @@ static int proxy_wstunnel_pump(ws_baton_t *baton, static void proxy_wstunnel_finish(ws_baton_t *baton) { + conn_rec *c = baton->r->connection; ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, baton->r, "proxy_wstunnel_finish"); baton->proxy_connrec->close = 1; /* new handshake expected on each back-conn */ - baton->r->connection->keepalive = AP_CONN_CLOSE; ap_proxy_release_connection(baton->scheme, baton->proxy_connrec, baton->r->server); - ap_finalize_request_protocol(baton->r); - ap_lingering_close(baton->r->connection); - apr_socket_close(baton->client_soc); - ap_mpm_resume_suspended(baton->r->connection); + ap_finalize_request_protocol(baton->r); /* send EOS */ + c->aborted = 1; /* nothing more on the client connection */ ap_process_request_after_handler(baton->r); /* don't touch baton or r after here */ + ap_mpm_resume_suspended(c); } /* If neither socket becomes readable in the specified timeout, Index: server/mpm/event/event.c =================================================================== --- server/mpm/event/event.c (revision 1840709) +++ server/mpm/event/event.c (working copy) @@ -1273,6 +1273,12 @@ static apr_status_t event_resume_suspended (conn_r apr_atomic_dec32(&suspended_count); c->suspended_baton = NULL; + if (c->aborted) { + apr_socket_close(ap_get_conn_socket(c)); + ap_queue_info_push_pool(worker_queue_info, cs->p); + return OK; + } + cs->queue_timestamp = apr_time_now(); cs->pfd.reqevents = ( cs->pub.sense == CONN_SENSE_WANT_READ ? APR_POLLIN :