Lines 26-31
Link Here
|
26 |
#include "httpd.h" |
26 |
#include "httpd.h" |
27 |
#include "http_main.h" |
27 |
#include "http_main.h" |
28 |
#include "http_core.h" |
28 |
#include "http_core.h" |
|
|
29 |
#include "ap_mpm.h" |
29 |
|
30 |
|
30 |
#define AP_SLOTMEM_IS_PREGRAB(t) (t->desc->type & AP_SLOTMEM_TYPE_PREGRAB) |
31 |
#define AP_SLOTMEM_IS_PREGRAB(t) (t->desc->type & AP_SLOTMEM_TYPE_PREGRAB) |
31 |
#define AP_SLOTMEM_IS_PERSIST(t) (t->desc->type & AP_SLOTMEM_TYPE_PERSIST) |
32 |
#define AP_SLOTMEM_IS_PERSIST(t) (t->desc->type & AP_SLOTMEM_TYPE_PERSIST) |
Lines 42-48
typedef struct {
Link Here
|
42 |
#define AP_UNSIGNEDINT_OFFSET (APR_ALIGN_DEFAULT(sizeof(unsigned int))) |
43 |
#define AP_UNSIGNEDINT_OFFSET (APR_ALIGN_DEFAULT(sizeof(unsigned int))) |
43 |
|
44 |
|
44 |
struct ap_slotmem_instance_t { |
45 |
struct ap_slotmem_instance_t { |
45 |
char *name; /* file based SHM path/name */ |
46 |
char *name; /* file based SHM name (immutable) */ |
|
|
47 |
char *fname; /* file based SHM path/name */ |
46 |
char *pname; /* persisted file path/name */ |
48 |
char *pname; /* persisted file path/name */ |
47 |
int fbased; /* filebased? */ |
49 |
int fbased; /* filebased? */ |
48 |
void *shm; /* ptr to memory segment (apr_shm_t *) */ |
50 |
void *shm; /* ptr to memory segment (apr_shm_t *) */ |
Lines 320-326
static apr_status_t cleanup_slotmem(void *is_start
Link Here
|
320 |
* unlink, thus call destroy() first. |
322 |
* unlink, thus call destroy() first. |
321 |
*/ |
323 |
*/ |
322 |
apr_shm_destroy(mem->shm); |
324 |
apr_shm_destroy(mem->shm); |
323 |
apr_shm_remove(mem->name, mem->pool); |
325 |
apr_shm_remove(mem->fname, mem->pool); |
324 |
} |
326 |
} |
325 |
} |
327 |
} |
326 |
|
328 |
|
Lines 368-386
static int check_slotmem(ap_slotmem_instance_t *me
Link Here
|
368 |
|
370 |
|
369 |
/* check size */ |
371 |
/* check size */ |
370 |
if (apr_shm_size_get(mem->shm) != size) { |
372 |
if (apr_shm_size_get(mem->shm) != size) { |
371 |
ap_log_error(APLOG_MARK, APLOG_ERR, 0, ap_server_conf, APLOGNO(02599) |
373 |
ap_log_error(APLOG_MARK, APLOG_INFO, 0, ap_server_conf, APLOGNO(02599) |
372 |
"existing shared memory for %s could not be used " |
374 |
"existing shared memory for %s could not be used " |
373 |
"(failed size check)", |
375 |
"(failed size check)", |
374 |
mem->name); |
376 |
mem->fname); |
375 |
return 0; |
377 |
return 0; |
376 |
} |
378 |
} |
377 |
|
379 |
|
378 |
desc = apr_shm_baseaddr_get(mem->shm); |
380 |
desc = apr_shm_baseaddr_get(mem->shm); |
379 |
if (desc->size != item_size || desc->num != item_num) { |
381 |
if (desc->size != item_size || desc->num != item_num) { |
380 |
ap_log_error(APLOG_MARK, APLOG_ERR, 0, ap_server_conf, APLOGNO(02600) |
382 |
ap_log_error(APLOG_MARK, APLOG_INFO, 0, ap_server_conf, APLOGNO(02600) |
381 |
"existing shared memory for %s could not be used " |
383 |
"existing shared memory for %s could not be used " |
382 |
"(failed contents check)", |
384 |
"(failed contents check)", |
383 |
mem->name); |
385 |
mem->fname); |
384 |
return 0; |
386 |
return 0; |
385 |
} |
387 |
} |
386 |
|
388 |
|
Lines 412-423
static apr_status_t slotmem_create(ap_slotmem_inst
Link Here
|
412 |
if (slotmem_filenames(pool, name, &fname, persist ? &pname : NULL)) { |
414 |
if (slotmem_filenames(pool, name, &fname, persist ? &pname : NULL)) { |
413 |
/* first try to attach to existing slotmem */ |
415 |
/* first try to attach to existing slotmem */ |
414 |
if (next) { |
416 |
if (next) { |
|
|
417 |
int generation = -1; |
415 |
ap_slotmem_instance_t *prev = NULL; |
418 |
ap_slotmem_instance_t *prev = NULL; |
416 |
for (;;) { |
419 |
for (;;) { |
417 |
if (strcmp(next->name, fname) == 0) { |
420 |
if (strcmp(next->name, name) == 0) { |
418 |
*new = next; /* either returned here or reused finally */ |
421 |
*new = next; /* either returned here or reused finally */ |
419 |
if (!check_slotmem(next, size, item_size, item_num)) { |
422 |
if (!check_slotmem(next, size, item_size, item_num)) { |
|
|
423 |
/* Can't reuse this SHM, a new one is needed with its |
424 |
* own filename (including generation number) because |
425 |
* the previous one may still be used by the previous |
426 |
* generation. Persisted file (if any) can't be reused |
427 |
* either. |
428 |
*/ |
420 |
apr_shm_destroy(next->shm); |
429 |
apr_shm_destroy(next->shm); |
|
|
430 |
apr_shm_remove(next->fname, pool); |
431 |
if (generation < 0) { |
432 |
ap_mpm_query(AP_MPMQ_GENERATION, &generation); |
433 |
} |
434 |
fname = apr_psprintf(pool, "%s.%i", fname, generation); |
435 |
persist = 0; |
436 |
|
421 |
next = next->next; |
437 |
next = next->next; |
422 |
if (prev) { |
438 |
if (prev) { |
423 |
prev->next = next; |
439 |
prev->next = next; |
Lines 516-525
static apr_status_t slotmem_create(ap_slotmem_inst
Link Here
|
516 |
res = *new; |
532 |
res = *new; |
517 |
if (res == NULL) { |
533 |
if (res == NULL) { |
518 |
res = apr_pcalloc(p, sizeof(ap_slotmem_instance_t)); |
534 |
res = apr_pcalloc(p, sizeof(ap_slotmem_instance_t)); |
519 |
res->name = apr_pstrdup(p, fname); |
535 |
res->name = apr_pstrdup(p, name); |
520 |
res->pname = apr_pstrdup(p, pname); |
536 |
res->pname = apr_pstrdup(p, pname); |
521 |
*new = res; |
537 |
*new = res; |
522 |
} |
538 |
} |
|
|
539 |
res->fname = apr_pstrdup(p, fname); |
523 |
res->fbased = fbased; |
540 |
res->fbased = fbased; |
524 |
res->shm = shm; |
541 |
res->shm = shm; |
525 |
res->persist = (void *)ptr; |
542 |
res->persist = (void *)ptr; |
Lines 568-574
static apr_status_t slotmem_attach(ap_slotmem_inst
Link Here
|
568 |
/* first try to attach to existing slotmem */ |
585 |
/* first try to attach to existing slotmem */ |
569 |
if (next) { |
586 |
if (next) { |
570 |
for (;;) { |
587 |
for (;;) { |
571 |
if (strcmp(next->name, fname) == 0) { |
588 |
if (strcmp(next->name, name) == 0) { |
572 |
/* we already have it */ |
589 |
/* we already have it */ |
573 |
*new = next; |
590 |
*new = next; |
574 |
*item_size = next->desc->size; |
591 |
*item_size = next->desc->size; |
Lines 598-604
static apr_status_t slotmem_attach(ap_slotmem_inst
Link Here
|
598 |
|
615 |
|
599 |
/* For the chained slotmem stuff */ |
616 |
/* For the chained slotmem stuff */ |
600 |
res = apr_pcalloc(pool, sizeof(ap_slotmem_instance_t)); |
617 |
res = apr_pcalloc(pool, sizeof(ap_slotmem_instance_t)); |
601 |
res->name = apr_pstrdup(pool, fname); |
618 |
res->name = apr_pstrdup(pool, name); |
|
|
619 |
res->fname = apr_pstrdup(pool, fname); |
602 |
res->fbased = 1; |
620 |
res->fbased = 1; |
603 |
res->shm = shm; |
621 |
res->shm = shm; |
604 |
res->persist = (void *)ptr; |
622 |
res->persist = (void *)ptr; |