View | Details | Raw Unified | Return to bug 44736
Collapse All | Expand All

(-)modules/proxy/mod_proxy.h (+5 lines)
Lines 308-313 Link Here
308
    void            *context;   /* general purpose storage */
308
    void            *context;   /* general purpose storage */
309
    apr_size_t      busy;       /* busyness factor */
309
    apr_size_t      busy;       /* busyness factor */
310
    int             lbset;      /* load balancer cluster set */
310
    int             lbset;      /* load balancer cluster set */
311
    unsigned char   digest[APR_MD5_DIGESTSIZE]; /* hash of the worker->name */
311
} proxy_worker_stat;
312
} proxy_worker_stat;
312
313
313
/* Worker configuration */
314
/* Worker configuration */
Lines 772-777 Link Here
772
ap_proxy_buckets_lifetime_transform(request_rec *r, apr_bucket_brigade *from,
773
ap_proxy_buckets_lifetime_transform(request_rec *r, apr_bucket_brigade *from,
773
                                        apr_bucket_brigade *to);
774
                                        apr_bucket_brigade *to);
774
775
776
#if PROXY_HAS_SCOREBOARD
777
void *ap_proxy_set_scoreboard_lb(proxy_worker *worker);
778
#endif
779
775
#define PROXY_LBMETHOD "proxylbmethod"
780
#define PROXY_LBMETHOD "proxylbmethod"
776
781
777
/* The number of dynamic workers that can be added when reconfiguring.
782
/* The number of dynamic workers that can be added when reconfiguring.
(-)modules/proxy/mod_proxy_balancer.c (-1 / +1 lines)
Lines 94-100 Link Here
94
             * If the worker is not initialized check whether its scoreboard
94
             * If the worker is not initialized check whether its scoreboard
95
             * slot is already initialized.
95
             * slot is already initialized.
96
             */
96
             */
97
            slot = (proxy_worker_stat *) ap_get_scoreboard_lb(workers->id);
97
            slot = (proxy_worker_stat *) ap_proxy_set_scoreboard_lb(workers);
98
            if (slot) {
98
            if (slot) {
99
                worker_is_initialized = slot->status & PROXY_WORKER_INITIALIZED;
99
                worker_is_initialized = slot->status & PROXY_WORKER_INITIALIZED;
100
            }
100
            }
(-)modules/proxy/proxy_util.c (-2 / +41 lines)
Lines 1794-1799 Link Here
1794
}
1794
}
1795
#endif
1795
#endif
1796
1796
1797
#if PROXY_HAS_SCOREBOARD
1798
void *ap_proxy_set_scoreboard_lb(proxy_worker *worker) {
1799
    int i = 0;
1800
    proxy_worker_stat *free_slot = NULL;
1801
    proxy_worker_stat *s;
1802
    unsigned char digest[APR_MD5_DIGESTSIZE];
1803
1804
    if (!ap_scoreboard_image) {
1805
        return NULL;
1806
    }
1807
1808
    if (worker->s) {
1809
        return worker->s;
1810
    }
1811
1812
    apr_md5(digest, (const unsigned char *) worker->name,
1813
            strlen(worker->name));
1814
1815
    /* Try to find out the right shared memory according to the hash
1816
     * of worker->name. */
1817
    while ((s = (proxy_worker_stat *)ap_get_scoreboard_lb(i++)) != NULL) {
1818
        if (memcmp(s->digest, digest, APR_MD5_DIGESTSIZE) == 0) {
1819
            worker->s = s;
1820
            return s; 
1821
        }
1822
        else if (s->status == 0 && free_slot == NULL) {
1823
            free_slot = s;
1824
        }
1825
    }
1826
1827
    /* We failed to find out shared memory, so just use free slot */
1828
    worker->s = free_slot;
1829
    return free_slot;
1830
};
1831
#endif
1832
1797
/*
1833
/*
1798
 * ap_proxy_initialize_worker_share() concerns itself
1834
 * ap_proxy_initialize_worker_share() concerns itself
1799
 * with initializing those parts of worker which
1835
 * with initializing those parts of worker which
Lines 1819-1828 Link Here
1819
#if PROXY_HAS_SCOREBOARD
1855
#if PROXY_HAS_SCOREBOARD
1820
        /* Get scoreboard slot */
1856
        /* Get scoreboard slot */
1821
    if (ap_scoreboard_image) {
1857
    if (ap_scoreboard_image) {
1822
        score = ap_get_scoreboard_lb(worker->id);
1858
        score = ap_proxy_set_scoreboard_lb(worker);
1823
        if (!score) {
1859
        if (!score) {
1824
            ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
1860
            ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
1825
                  "proxy: ap_get_scoreboard_lb(%d) failed in child %" APR_PID_T_FMT " for worker %s",
1861
                  "proxy: ap_proxy_get_scoreboard_lb(%d) failed in child %" APR_PID_T_FMT " for worker %s",
1826
                  worker->id, getpid(), worker->name);
1862
                  worker->id, getpid(), worker->name);
1827
        }
1863
        }
1828
        else {
1864
        else {
Lines 1863-1868 Link Here
1863
        *worker->s->redirect = '\0';
1899
        *worker->s->redirect = '\0';
1864
    }
1900
    }
1865
1901
1902
    apr_md5(worker->s->digest, (const unsigned char *) worker->name,
1903
            strlen(worker->name));
1904
1866
    worker->s->status |= (worker->status | PROXY_WORKER_INITIALIZED);
1905
    worker->s->status |= (worker->status | PROXY_WORKER_INITIALIZED);
1867
1906
1868
}
1907
}

Return to bug 44736