stoddard@apache.org wrote:
>
>
> +/* Is the scoreboard shared between processes or not?
> + * Set by the MPM when the scoreboard is created.
> + */
> +typedef enum {
> + SB_SHARED = 1,
> + SB_NOT_SHARED = 2
> +} ap_scoreboard_e;
> +
...
> +
> +/* ap_create_scoreboard(apr_pool_t*, ap_scoreboard_e t)
> + *
> + * Create or reinit an existing scoreboard. The MPM can control whether
> + * the scoreboard is shared across multiple processes or not
> + */
> +AP_DECLARE(void) ap_create_scoreboard(apr_pool_t *p, ap_scoreboard_e sb_type)
> {
> int running_gen = 0;
> if (ap_scoreboard_image)
> running_gen = ap_scoreboard_image->global.running_generation;
> if (ap_scoreboard_image == NULL) {
> - setup_shared_mem(p);
> + if (sb_type == SB_SHARED) {
> + setup_shared(p);
> + ap_scoreboard_image->global.sb_type = SB_SHARED;
> + }
> + else {
> + /* A simple malloc will suffice */
> + char buf[512];
> + ap_scoreboard_image = (scoreboard *) malloc(SCOREBOARD_SIZE);
> + if (ap_scoreboard_image == NULL) {
> + apr_snprintf(buf, sizeof(buf), "%s: cannot allocate scoreboard",
> + ap_server_argv0);
> + perror(buf); /* o.k. since MM sets errno */
> + exit(APEXIT_INIT);
> + }
> + ap_scoreboard_image->global.sb_type = SB_NOT_SHARED;
> + }
> }
I may not be looking far enough ahead for this, but it seems
to me that the abstraction should be at a higher level. That
is setup_shared_mem() should "do the right thing." And there
should be even higher abstraction for all the various
shared mems (ala MM but leaner)... Does this make sense?
Ideally, APR should handle this.
--
===========================================================================
Jim Jagielski [|] jim@jaguNET.com [|] http://www.jaguNET.com/
"Casanova will have many weapons; To beat him you will
have to have more than forks and flatulence."
|