MCPcopy Create free account
hub / github.com/apache/httpd / ap_create_scoreboard

Function ap_create_scoreboard

server/scoreboard.c:304–349  ·  view source on GitHub ↗

Create or reinit an existing scoreboard. The MPM can control whether * the scoreboard is shared across multiple processes or not */

Source from the content-addressed store, hash-verified

302 * the scoreboard is shared across multiple processes or not
303 */
304int ap_create_scoreboard(apr_pool_t *p, ap_scoreboard_e sb_type)
305{
306 int i;
307#if APR_HAS_SHARED_MEMORY
308 apr_status_t rv;
309#endif
310
311 if (ap_scoreboard_image) {
312 ap_scoreboard_image->global->restart_time = apr_time_now();
313 memset(ap_scoreboard_image->parent, 0,
314 SIZE_OF_process_score * server_limit);
315 for (i = 0; i < server_limit; i++) {
316 memset(ap_scoreboard_image->servers[i], 0,
317 SIZE_OF_worker_score * thread_limit);
318 }
319 ap_init_scoreboard(NULL);
320 return OK;
321 }
322
323 ap_calc_scoreboard_size();
324#if APR_HAS_SHARED_MEMORY
325 if (sb_type == SB_SHARED) {
326 void *sb_shared;
327 rv = open_scoreboard(p);
328 if (rv || !(sb_shared = apr_shm_baseaddr_get(ap_scoreboard_shm))) {
329 return HTTP_INTERNAL_SERVER_ERROR;
330 }
331 memset(sb_shared, 0, scoreboard_size);
332 ap_init_scoreboard(sb_shared);
333 }
334 else
335#endif
336 {
337 /* A simple malloc will suffice */
338 void *sb_mem = ap_calloc(1, scoreboard_size);
339 ap_init_scoreboard(sb_mem);
340 }
341
342 scoreboard_type = sb_type;
343 ap_scoreboard_image->global->running_generation = 0;
344 ap_scoreboard_image->global->restart_time = apr_time_now();
345
346 apr_pool_cleanup_register(p, NULL, ap_cleanup_scoreboard, apr_pool_cleanup_null);
347
348 return OK;
349}
350
351/* Routines called to deal with the scoreboard image
352 * --- note that we do *not* need write locks, since update_child_status

Callers

nothing calls this directly

Calls 4

ap_init_scoreboardFunction · 0.85
ap_calc_scoreboard_sizeFunction · 0.85
open_scoreboardFunction · 0.85
ap_callocFunction · 0.85

Tested by

no test coverage detected