https://issues.apache.org/bugzilla/show_bug.cgi?id=44736

--- Comment #32 from Yann Ylavic <[email protected]> ---
(In reply to jkaluza from comment #31)
> I already have it in my patches (or am I missing something)?
> 
> -            slot = (proxy_worker_stat *) ap_get_scoreboard_lb(workers->id);
> +            slot = (proxy_worker_stat *)
> ap_proxy_get_scoreboard_lb(workers);

Sorry, it was based on your previous comment, and I didn't update the page to
see the latest patch.

Maybe you can add a fast path in ap_proxy_get_scoreboard_lb() with something
like :

+void *ap_proxy_set_scoreboard_lb(proxy_worker *worker) {
+    int i = 0;
+    proxy_worker_stat *free_slot = NULL;
+    proxy_worker_stat *s;
+    unsigned char digest[APR_MD5_DIGESTSIZE];
+
+    if (!ap_scoreboard_image) {
+        return NULL;
+    }
     if (worker->s) {
         return worker->s;
     }
+
+    apr_md5(digest, (const unsigned char *) worker->name,
+            strlen(worker->name));
+
+    /* Try to find out the right shared memory according to the hash
+     * of worker->name. */
+    while ((s = (proxy_worker_stat *)ap_get_scoreboard_lb(i++)) != NULL) {
+        if (memcmp(s->digest, digest, APR_MD5_DIGESTSIZE) == 0) {
             worker->s = s;
+            return s;
+        }
+        else if (s->status == 0 && free_slot == NULL) {
+            free_slot = s;
+        }
+    }
+
+    /* We failed to find out shared memory, so just use free slot */
     worker->s = free_slot;
+    return free_slot;
+}

so that the double call from init_balancer_members() does not hurt.
(Note that I renamed it ap_proxy_set_scoreboard_lb, according to the
changes...)

Apologies (again) to propose partial things each time, this is the last one I
hope.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to