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

(-)trunk/include/scoreboard.h (-3 / +3 lines)
Lines 163-169 Link Here
163
AP_DECLARE(int) ap_exists_scoreboard_image(void);
163
AP_DECLARE(int) ap_exists_scoreboard_image(void);
164
AP_DECLARE(void) ap_increment_counts(ap_sb_handle_t *sbh, request_rec *r);
164
AP_DECLARE(void) ap_increment_counts(ap_sb_handle_t *sbh, request_rec *r);
165
165
166
int ap_create_scoreboard(apr_pool_t *p, ap_scoreboard_e t);
166
int ap_create_scoreboard(apr_pool_t *pglobal, ap_scoreboard_e t);
167
apr_status_t ap_reopen_scoreboard(apr_pool_t *p, apr_shm_t **shm, int detached);
167
apr_status_t ap_reopen_scoreboard(apr_pool_t *p, apr_shm_t **shm, int detached);
168
void ap_init_scoreboard(void *shared_score);
168
void ap_init_scoreboard(void *shared_score);
169
AP_DECLARE(int) ap_calc_scoreboard_size(void);
169
AP_DECLARE(int) ap_calc_scoreboard_size(void);
Lines 192-203 Link Here
192
/* Hooks */
192
/* Hooks */
193
/**
193
/**
194
  * Hook for post scoreboard creation, pre mpm.
194
  * Hook for post scoreboard creation, pre mpm.
195
  * @param p       Apache pool to allocate from.
195
  * @param pglobal       Apache pool to allocate from.
196
  * @param sb_type 
196
  * @param sb_type 
197
  * @ingroup hooks
197
  * @ingroup hooks
198
  * @return OK or DECLINE on success; anything else is a error
198
  * @return OK or DECLINE on success; anything else is a error
199
  */  
199
  */  
200
AP_DECLARE_HOOK(int, pre_mpm, (apr_pool_t *p, ap_scoreboard_e sb_type))
200
AP_DECLARE_HOOK(int, pre_mpm, (apr_pool_t *pglobal, ap_scoreboard_e sb_type))
201
201
202
/**
202
/**
203
  * proxy load balancer
203
  * proxy load balancer
(-)trunk/modules/experimental/mod_example.c (-1 / +1 lines)
Lines 1384-1390 Link Here
1384
 * 
1384
 * 
1385
 * This is a RUN_ALL hook. 
1385
 * This is a RUN_ALL hook. 
1386
 */
1386
 */
1387
static int x_pre_mpm(apr_pool_t *p, ap_scoreboard_e sb_type)
1387
static int x_pre_mpm(apr_pool_t *pglobal, ap_scoreboard_e sb_type)
1388
{
1388
{
1389
    trace_nocontext(p, __FILE__, __LINE__, "x_pre_mpm()");
1389
    trace_nocontext(p, __FILE__, __LINE__, "x_pre_mpm()");
1390
    return DECLINED;
1390
    return DECLINED;
(-)trunk/server/scoreboard.c (-23 / +11 lines)
Lines 57-64 Link Here
57
)
57
)
58
58
59
AP_IMPLEMENT_HOOK_RUN_ALL(int,pre_mpm,
59
AP_IMPLEMENT_HOOK_RUN_ALL(int,pre_mpm,
60
                          (apr_pool_t *p, ap_scoreboard_e sb_type),
60
                          (apr_pool_t *pglobal, ap_scoreboard_e sb_type),
61
                          (p, sb_type),OK,DECLINED)
61
                          (pglobal, sb_type),OK,DECLINED)
62
62
63
static APR_OPTIONAL_FN_TYPE(ap_proxy_lb_workers)
63
static APR_OPTIONAL_FN_TYPE(ap_proxy_lb_workers)
64
                                *pfn_proxy_lb_workers;
64
                                *pfn_proxy_lb_workers;
Lines 177-215 Link Here
177
 * a scoreboard shared between processes using any IPC technique,
177
 * a scoreboard shared between processes using any IPC technique,
178
 * not just a shared memory segment
178
 * not just a shared memory segment
179
 */
179
 */
180
static apr_status_t open_scoreboard(apr_pool_t *pconf)
180
static apr_status_t open_scoreboard(apr_pool_t *pglobal)
181
{
181
{
182
#if APR_HAS_SHARED_MEMORY
182
#if APR_HAS_SHARED_MEMORY
183
    apr_status_t rv;
183
    apr_status_t rv;
184
    char *fname = NULL;
184
    char *fname = NULL;
185
    apr_pool_t *global_pool;
186
185
187
    /* We don't want to have to recreate the scoreboard after
188
     * restarts, so we'll create a global pool and never clean it.
189
     */
190
    rv = apr_pool_create(&global_pool, NULL);
191
    if (rv != APR_SUCCESS) {
192
        ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL,
193
                     "Fatal error: unable to create global pool "
194
                     "for use by the scoreboard");
195
        return rv;
196
    }
197
198
    /* The config says to create a name-based shmem */
186
    /* The config says to create a name-based shmem */
199
    if (ap_scoreboard_fname) {
187
    if (ap_scoreboard_fname) {
200
        /* make sure it's an absolute pathname */
188
        /* make sure it's an absolute pathname */
201
        fname = ap_server_root_relative(pconf, ap_scoreboard_fname);
189
        fname = ap_server_root_relative(pglobal, ap_scoreboard_fname);
202
        if (!fname) {
190
        if (!fname) {
203
            ap_log_error(APLOG_MARK, APLOG_CRIT, APR_EBADPATH, NULL,
191
            ap_log_error(APLOG_MARK, APLOG_CRIT, APR_EBADPATH, NULL,
204
                         "Fatal error: Invalid Scoreboard path %s",
192
                         "Fatal error: Invalid Scoreboard path %s",
205
                         ap_scoreboard_fname);
193
                         ap_scoreboard_fname);
206
            return APR_EBADPATH;
194
            return APR_EBADPATH;
207
        }
195
        }
208
        return create_namebased_scoreboard(global_pool, fname);
196
        return create_namebased_scoreboard(pglobal, fname);
209
    }
197
    }
210
    else { /* config didn't specify, we get to choose shmem type */
198
    else { /* config didn't specify, we get to choose shmem type */
211
        rv = apr_shm_create(&ap_scoreboard_shm, scoreboard_size, NULL,
199
        rv = apr_shm_create(&ap_scoreboard_shm, scoreboard_size, NULL,
212
                            global_pool); /* anonymous shared memory */
200
                            pglobal); /* anonymous shared memory */
213
        if ((rv != APR_SUCCESS) && (rv != APR_ENOTIMPL)) {
201
        if ((rv != APR_SUCCESS) && (rv != APR_ENOTIMPL)) {
214
            ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL,
202
            ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL,
215
                         "Unable to create or access scoreboard "
203
                         "Unable to create or access scoreboard "
Lines 220-228 Link Here
220
        else if (rv == APR_ENOTIMPL) {
208
        else if (rv == APR_ENOTIMPL) {
221
            /* Make sure it's an absolute pathname */
209
            /* Make sure it's an absolute pathname */
222
            ap_scoreboard_fname = DEFAULT_SCOREBOARD;
210
            ap_scoreboard_fname = DEFAULT_SCOREBOARD;
223
            fname = ap_server_root_relative(pconf, ap_scoreboard_fname);
211
            fname = ap_server_root_relative(pglobal, ap_scoreboard_fname);
224
212
225
            return create_namebased_scoreboard(global_pool, fname);
213
            return create_namebased_scoreboard(pglobal, fname);
226
        }
214
        }
227
    }
215
    }
228
#endif /* APR_HAS_SHARED_MEMORY */
216
#endif /* APR_HAS_SHARED_MEMORY */
Lines 272-278 Link Here
272
/* Create or reinit an existing scoreboard. The MPM can control whether
260
/* Create or reinit an existing scoreboard. The MPM can control whether
273
 * the scoreboard is shared across multiple processes or not
261
 * the scoreboard is shared across multiple processes or not
274
 */
262
 */
275
int ap_create_scoreboard(apr_pool_t *p, ap_scoreboard_e sb_type)
263
int ap_create_scoreboard(apr_pool_t *pglobal, ap_scoreboard_e sb_type)
276
{
264
{
277
    int running_gen = 0;
265
    int running_gen = 0;
278
    int i;
266
    int i;
Lines 301-307 Link Here
301
#if APR_HAS_SHARED_MEMORY
289
#if APR_HAS_SHARED_MEMORY
302
    if (sb_type == SB_SHARED) {
290
    if (sb_type == SB_SHARED) {
303
        void *sb_shared;
291
        void *sb_shared;
304
        rv = open_scoreboard(p);
292
        rv = open_scoreboard(pglobal);
305
        if (rv || !(sb_shared = apr_shm_baseaddr_get(ap_scoreboard_shm))) {
293
        if (rv || !(sb_shared = apr_shm_baseaddr_get(ap_scoreboard_shm))) {
306
            return HTTP_INTERNAL_SERVER_ERROR;
294
            return HTTP_INTERNAL_SERVER_ERROR;
307
        }
295
        }
Lines 326-332 Link Here
326
    ap_scoreboard_image->global->running_generation = running_gen;
314
    ap_scoreboard_image->global->running_generation = running_gen;
327
    ap_scoreboard_image->global->restart_time = apr_time_now();
315
    ap_scoreboard_image->global->restart_time = apr_time_now();
328
316
329
    apr_pool_cleanup_register(p, NULL, ap_cleanup_scoreboard, apr_pool_cleanup_null);
317
    apr_pool_cleanup_register(pglobal, NULL, ap_cleanup_scoreboard, apr_pool_cleanup_null);
330
318
331
    return OK;
319
    return OK;
332
}
320
}

Return to bug 43471