dgaudet 97/07/23 21:35:51
Modified: src CHANGES Configure conf.h http_main.c Log: QNX mmap() support. Submitted by: Igor N Kovalenko <[EMAIL PROTECTED]> Reviewed by: Dean Gaudet PR: 683 Revision Changes Path 1.363 +3 -0 apache/src/CHANGES Index: CHANGES =================================================================== RCS file: /export/home/cvs/apache/src/CHANGES,v retrieving revision 1.362 retrieving revision 1.363 diff -u -r1.362 -r1.363 --- CHANGES 1997/07/24 04:32:27 1.362 +++ CHANGES 1997/07/24 04:35:43 1.363 @@ -1,5 +1,8 @@ Changes with Apache 1.3a2 + *) PORT: QNX mmap() support for faster/more reliable scoreboard handling. + [Igor N Kovalenko <[EMAIL PROTECTED]>] PR#683 + *) child_main avoids an uneeded call to select() when there is only one listening socket. [Dean Gaudet] 1.120 +2 -2 apache/src/Configure Index: Configure =================================================================== RCS file: /export/home/cvs/apache/src/Configure,v retrieving revision 1.119 retrieving revision 1.120 diff -u -r1.119 -r1.120 --- Configure 1997/07/21 23:09:30 1.119 +++ Configure 1997/07/24 04:35:45 1.120 @@ -357,13 +357,13 @@ *-qnx) OS='QNX' CFLAGS="$CFLAGS -DQNX" - LIBS="$LIBS -N128k -lsocket" + LIBS="$LIBS -N128k -lsocket -lunix" DEF_WANTHSREGEX=yes ;; *-qnx32) OS='QNX32' CFLAGS="$CFLAGS -DQNX -mf -3" - LIBS="$LIBS -N128k -lsocket" + LIBS="$LIBS -N128k -lsocket -lunix" DEF_WANTHSREGEX=yes ;; *-isc4*) 1.117 +1 -0 apache/src/conf.h Index: conf.h =================================================================== RCS file: /export/home/cvs/apache/src/conf.h,v retrieving revision 1.116 retrieving revision 1.117 diff -u -r1.116 -r1.117 --- conf.h 1997/07/21 03:37:48 1.116 +++ conf.h 1997/07/24 04:35:46 1.117 @@ -442,6 +442,7 @@ #define HAVE_SYS_SELECT_H #include <unix.h> #define JMP_BUF sigjmp_buf +#define HAVE_MMAP #elif defined(LYNXOS) #undef NO_KILLPG 1.187 +51 -0 apache/src/http_main.c Index: http_main.c =================================================================== RCS file: /export/home/cvs/apache/src/http_main.c,v retrieving revision 1.186 retrieving revision 1.187 diff -u -r1.186 -r1.187 --- http_main.c 1997/07/24 04:32:28 1.186 +++ http_main.c 1997/07/24 04:35:47 1.187 @@ -804,6 +804,55 @@ fprintf(stderr, "httpd: Could not uopen() newly created OS/2 Shared memory pool.\n"); } +#elif defined(QNX) +/* + * POSIX 1003.4 style + * + * Note 1: + * As of version 4.23A, shared memory in QNX must reside under /dev/shmem, + * where no subdirectories allowed. + * + * POSIX shm_open() and shm_unlink() will take care about this issue, + * but to avoid confusion, I suggest to redefine scoreboard file name + * in httpd.conf to cut "logs/" from it. With default setup actual name + * will be "/dev/shmem/logs.apache_status". + * + * If something went wrong and Apache did not unlinked this object upon + * exit, you can remove it manually, using "rm -f" command. + * + * Note 2: + * <sys/mman.h> in QNX defines MAP_ANON, but current implementation + * does NOT support BSD style anonymous mapping. So, the order of + * conditional compilation is important: + * this #ifdef section must be ABOVE the next one (BSD style). + * + * I tested this stuff and it works fine for me, but if it provides + * trouble for you, just comment out HAVE_MMAP in QNX section of conf.h + * + * June 5, 1997, + * Igor N. Kovalenko -- [EMAIL PROTECTED] + */ + int fd; + + fd = shm_open (scoreboard_fname, O_RDWR|O_CREAT, S_IRUSR|S_IWUSR); + if (fd == -1) { + perror("httpd: could not open(create) scoreboard"); + exit(1); + } + if (ltrunc(fd, (off_t)SCOREBOARD_SIZE, SEEK_SET) == -1) { + perror("httpd: could not ltrunc scoreboard"); + shm_unlink(scoreboard_fname); + exit(1); + } + if ((m = (caddr_t)mmap((caddr_t)0, + (size_t)SCOREBOARD_SIZE, PROT_READ|PROT_WRITE, + MAP_SHARED, fd, (off_t)0)) == (caddr_t)-1) { + perror("httpd: cannot mmap scoreboard"); + shm_unlink(scoreboard_fname); + exit(1); + } + close(fd); + #elif defined(MAP_ANON) || defined(MAP_FILE) /* BSD style */ m = mmap((caddr_t)0, SCOREBOARD_SIZE, @@ -1043,6 +1092,8 @@ { #ifdef SCOREBOARD_FILE unlink (scoreboard_fname); +#elif defined(QNX) && defined(HAVE_MMAP) + shm_unlink(scoreboard_fname); #endif }