On Fri, Jul 20, 2018 at 12:13 PM, Ruediger Pluem <rpl...@apache.org> wrote:
>
> Something like the attached? The mod_lbmethod_byrequests.c part needs to be 
> done for lb modules though.

+/* post_config hook: */
+static int lbmethod_byrequests_post_config(apr_pool_t *pconf, apr_pool_t *plog,
+        apr_pool_t *ptemp, server_rec *s)
+{
+
+    /* lbmethod_byrequests_post_config() will be called twice during
startup.  So, don't
+     * set up the static data the 1st time through. */
+    if (ap_state_query(AP_SQ_MAIN_STATE) == AP_SQ_MS_CREATE_PRE_CONFIG) {
+        return OK;
+    }
+
+    if (!ap_proxy_balancer_get_best_worker_fn) {

Shouldn't we remove this check to retrieve the function pointer unconditionally?
With static linking the pointer may not be NULL but still point to
garbage (mod_lbmethod_byrequests linked statically but mod_proxy
linked dynamically, if that's ever possible). APR_RETRIEVE_OPTIONAL_FN
is cheap anyway.

+        ap_proxy_balancer_get_best_worker_fn =
+                APR_RETRIEVE_OPTIONAL_FN(ap_proxy_balancer_get_best_worker);
+        if (!ap_proxy_balancer_get_best_worker_fn) {
+            ap_log_error(APLOG_MARK, APLOG_EMERG, 0, s, APLOGNO()
+                         "mod_proxy must be loaded for
mod_lbmethod_byrequests");
+            return !OK;
+        }
+    }
+
+    return OK;
+}

Otherwise, the patch looks good to me, thanks!

Regards,
Yann.

Reply via email to