httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Jagielski <...@hyperreal.com>
Subject cvs commit: apache/src http_main.c
Date Thu, 11 Apr 1996 19:38:41 GMT
jim         96/04/11 12:38:40

  Modified:    src       http_main.c
  Log:
  centralize shared memory support mmap/shmget
  
  Revision  Changes    Path
  1.22      +39 -39    apache/src/http_main.c
  
  Index: http_main.c
  ===================================================================
  RCS file: /export/home/cvs/apache/src/http_main.c,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -C3 -r1.21 -r1.22
  *** http_main.c	1996/04/09 08:18:38	1.21
  --- http_main.c	1996/04/11 19:38:38	1.22
  ***************
  *** 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();
        }
  
  
  

Mime
View raw message