]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Make AJP flushing admin configurable.
authorJim Jagielski <jim@apache.org>
Thu, 9 Mar 2006 18:39:16 +0000 (18:39 +0000)
committerJim Jagielski <jim@apache.org>
Thu, 9 Mar 2006 18:39:16 +0000 (18:39 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@384580 13f79535-47bb-0310-9956-ffa450edef68

modules/proxy/mod_proxy.c
modules/proxy/mod_proxy.h
modules/proxy/mod_proxy_ajp.c
modules/proxy/proxy_util.c

index 4eab150829ee410490b78e7fff89ee5fb2f699b5..4c0b950edf5df460ce9826234bc39060cadc8761 100644 (file)
@@ -218,6 +218,26 @@ static const char *set_worker_param(apr_pool_t *p,
             }
         }
     }
+    else if (!strcasecmp(key, "ajpflushpackets")) {
+        if (!strcasecmp(val, "on"))
+            worker->ajp_flush_packets = ajp_flush_on;
+        else if (!strcasecmp(val, "off"))
+            worker->ajp_flush_packets = ajp_flush_off;
+        else if (!strcasecmp(val, "auto"))
+            worker->ajp_flush_packets = ajp_flush_auto;
+        else
+            return "FlushPackets must be On|Off|Auto";
+    }
+    else if (!strcasecmp(key, "ajpflushwait")) {
+        ival = atoi(val);
+        if (ival > 1000 || ival < 0) {
+            return "AJPFlushWait must be <= 1000, or 0 for system default of 10 millseconds.";
+        }
+        if (ival == 0)
+            worker->ajp_flush_wait = AJP_FLUSH_WAIT;
+        else
+            worker->ajp_flush_wait = ival * 1000;    /* change to microseconds */
+    }
     else {
         return "unknown Worker parameter";
     }
index 7bc092eac0480660200b36ccf438944db8aa36ea..d54fd45f877cd4b76dfc22c3bb15f5afe9848c67 100644 (file)
@@ -301,9 +301,21 @@ struct proxy_worker {
 #if APR_HAS_THREADS
     apr_thread_mutex_t  *mutex;  /* Thread lock for updating address cache */
 #endif
-    void            *context;   /* general purpose storage */
+    void                *context;   /* general purpose storage */
+    enum {
+         ajp_flush_off,
+         ajp_flush_on,
+         ajp_flush_auto
+    } ajp_flush_packets;           /* control AJP flushing */
+    int                 ajp_flush_wait;  /* poll wait time in microseconds if flush_auto */
 };
 
+/*
+ * Wait 10000 microseconds to find out if more data is currently
+ * available at the backend. Just an arbitrary choose.
+ */
+#define AJP_FLUSH_WAIT 10000
+
 struct proxy_balancer {
     apr_array_header_t *workers; /* array of proxy_workers */
     const char *name;            /* name of the load balancer */
index 3c97162cced75e7ebd07bd395679ed5fa433aa46..2a7ec32988cc549dd619e89c610f606d5add3788 100644 (file)
@@ -90,7 +90,7 @@ static int proxy_ajp_canon(request_rec *r, char *url)
 }
 
 /*
- * XXX: Flushing bandaid
+ * XXX: AJP Auto Flushing
  *
  * When processing CMD_AJP13_SEND_BODY_CHUNK AJP messages we will do a poll
  * with FLUSH_WAIT miliseconds timeout to determine if more data is currently
@@ -105,15 +105,6 @@ static int proxy_ajp_canon(request_rec *r, char *url)
  * For further discussion see PR37100.
  * http://issues.apache.org/bugzilla/show_bug.cgi?id=37100
  */
-#define FLUSHING_BANDAID 1
-
-#ifdef FLUSHING_BANDAID
-/*
- * Wait 10000 microseconds to find out if more data is currently
- * available at the backend. Just an arbitrary choose.
- */
-#define FLUSH_WAIT 10000
-#endif
 
 /*
  * process the request and write the response.
@@ -140,10 +131,8 @@ static int ap_proxy_ajp_request(apr_pool_t *p, request_rec *r,
     apr_off_t bb_len;
     int data_sent = 0;
     int rv = 0;
-#ifdef FLUSHING_BANDAID
     apr_int32_t conn_poll_fd;
     apr_pollfd_t *conn_poll;
-#endif
 
     /*
      * Send the AJP request to the remote server
@@ -250,9 +239,8 @@ static int ap_proxy_ajp_request(apr_pool_t *p, request_rec *r,
     result = ajp_parse_type(r, conn->data);
     output_brigade = apr_brigade_create(p, r->connection->bucket_alloc);
 
-#ifdef FLUSHING_BANDAID
     /*
-     * Prepare apr_pollfd_t struct for later check if there is currently
+     * Prepare apr_pollfd_t struct for possible later check if there is currently
      * data available from the backend (do not flush response to client)
      * or not (flush response to client)
      */
@@ -260,7 +248,6 @@ static int ap_proxy_ajp_request(apr_pool_t *p, request_rec *r,
     conn_poll->reqevents = APR_POLLIN;
     conn_poll->desc_type = APR_POLL_SOCKET;
     conn_poll->desc.s = conn->sock;
-#endif
 
     bufsiz = AJP13_MAX_SEND_BODY_SZ;
     while (isok) {
@@ -330,17 +317,14 @@ static int ap_proxy_ajp_request(apr_pool_t *p, request_rec *r,
                                                     r->connection->bucket_alloc);
                     APR_BRIGADE_INSERT_TAIL(output_brigade, e);
 
-#ifdef FLUSHING_BANDAID
-                    /*
-                     * If there is no more data available from backend side
-                     * currently, flush response to client.
-                     */
-                    if (apr_poll(conn_poll, 1, &conn_poll_fd, FLUSH_WAIT)
-                        == APR_TIMEUP) {
+                    if ( (conn->worker->ajp_flush_packets == ajp_flush_on) ||
+                         ( (conn->worker->ajp_flush_packets == ajp_flush_auto) &&
+                           (apr_poll(conn_poll, 1, &conn_poll_fd,
+                                     conn->worker->ajp_flush_wait)
+                             == APR_TIMEUP) ) ) {
                         e = apr_bucket_flush_create(r->connection->bucket_alloc);
                         APR_BRIGADE_INSERT_TAIL(output_brigade, e);
                     }
-#endif
                     apr_brigade_length(output_brigade, 0, &bb_len);
                     if (bb_len != -1)
                         conn->worker->s->read += bb_len;
@@ -366,6 +350,7 @@ static int ap_proxy_ajp_request(apr_pool_t *p, request_rec *r,
                                   "proxy: error processing body");
                     isok = 0;
                 }
+                /* XXX: what about flush here? See mod_jk */
                 data_sent = 1;
                 break;
             default:
index a52a146b8397fcdf362c09b4b53203902c69ab23..3a8f288a6304c10c1d79dda3851bd9b990ed162c 100644 (file)
@@ -1318,6 +1318,8 @@ PROXY_DECLARE(const char *) ap_proxy_add_worker(proxy_worker **worker,
     (*worker)->hostname = uri.hostname;
     (*worker)->port = uri.port;
     (*worker)->id   = proxy_lb_workers;
+    (*worker)->ajp_flush_packets = ajp_flush_off;
+    (*worker)->ajp_flush_wait = AJP_FLUSH_WAIT;
     /* Increase the total worker count */
     proxy_lb_workers++;
     init_conn_pool(p, *worker);