You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Jim Jagielski <ji...@jaguNET.com> on 1996/04/11 15:22:56 UTC
Before I commit, please test
In preparation of the patches to dump the scoreboard from memory when
httpd is killed (and the reading of the dump when httpd is restarted) I've
a small patch that centralizes some shared memory stuff.
It's a simple block move of code, but before I commit, could someone test it
and make sure it still compiles OK (assuming you're using mmap())...
Once I get the word it works OK, I'll commit and finish up.
Index: apache/src/http_main.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_main.c,v
retrieving revision 1.21
diff -c -r1.21 http_main.c
*** http_main.c 1996/04/09 08:18:38 1.21
--- http_main.c 1996/04/11 13:15:47
***************
*** 422,427 ****
--- 422,465 ----
#if defined(HAVE_MMAP)
static short_score *scoreboard_image=NULL;
+
+ static void setup_shared_mem(void)
+ {
+ caddr_t m;
+ #if defined(MAP_ANON) || defined(MAP_FILE)
+ /* BSD style */
+ m = mmap((caddr_t)0, HARD_SERVER_MAX*sizeof(short_score),
+ PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0);
+ if (m == (caddr_t)-1)
+ {
+ perror("mmap");
+ fprintf(stderr, "httpd: Could not mmap memory\n");
+ exit(1);
+ }
+ #else
+ /* Sun style */
+ int fd;
+
+ fd = open("/dev/zero", O_RDWR);
+ if (fd == -1)
+ {
+ perror("open");
+ fprintf(stderr, "httpd: Could not open /dev/zero\n");
+ exit(1);
+ }
+ m = mmap((caddr_t)0, HARD_SERVER_MAX*sizeof(short_score),
+ PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ if (m == (caddr_t)-1)
+ {
+ perror("mmap");
+ fprintf(stderr, "httpd: Could not mmap /dev/zero\n");
+ exit(1);
+ }
+ close(fd);
+ #endif
+ scoreboard_image = (short_score *)m;
+ }
+
#elif defined(HAVE_SHMGET)
static short_score *scoreboard_image=NULL;
static key_t shmkey = IPC_PRIVATE;
***************
*** 551,596 ****
/* Called by parent process */
void reinit_scoreboard (pool *p)
{
! #if defined(HAVE_MMAP)
if (scoreboard_image == NULL)
- {
- caddr_t m;
- #if defined(MAP_ANON) || defined(MAP_FILE)
- /* BSD style */
- m = mmap((caddr_t)0, HARD_SERVER_MAX*sizeof(short_score),
- PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0);
- if (m == (caddr_t)-1)
- {
- perror("mmap");
- fprintf(stderr, "httpd: Could not mmap memory\n");
- exit(1);
- }
- #else
- /* Sun style */
- int fd;
-
- fd = open("/dev/zero", O_RDWR);
- if (fd == -1)
- {
- perror("open");
- fprintf(stderr, "httpd: Could not open /dev/zero\n");
- exit(1);
- }
- m = mmap((caddr_t)0, HARD_SERVER_MAX*sizeof(short_score),
- PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
- if (m == (caddr_t)-1)
- {
- perror("mmap");
- fprintf(stderr, "httpd: Could not mmap /dev/zero\n");
- exit(1);
- }
- close(fd);
- #endif
- scoreboard_image = (short_score *)m;
- }
- memset(scoreboard_image, 0, HARD_SERVER_MAX*sizeof(short_score));
- #elif defined(HAVE_SHMGET)
- if (scoreboard_image == NULL )
{
setup_shared_mem();
}
--- 589,596 ----
/* Called by parent process */
void reinit_scoreboard (pool *p)
{
! #if defined(HAVE_SHMGET) || defined(HAVE_MMAP)
if (scoreboard_image == NULL)
{
setup_shared_mem();
}
--
Jim Jagielski << jim@jaguNET.com >> | "That's a Smith & Wesson,
** jaguNET Access Services ** | and you've had your six"
Email: info@jaguNET.com | - James Bond
++ http://www.jaguNET.com/ +++ Voice/Fax: 410-931-3157 ++