You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Dean Gaudet <dg...@arctic.org> on 1997/07/21 01:58:31 UTC
[PATCH] PR#683: QNX mmap() support
I checked with a friend at QNX and this should work fine on all 32-bit
versions of QNX. Which makes me suspect the first hunk of the Configure
change below ... but we'll have a whole alpha/beta cycle to get that
problem cleaned up, if it is a problem. With that in mind, anyone mind if
I commit this?
Oh yeah, if I understand his comment about no subdirectories under
/dev/shmem, the OS or C library takes care of '/' characters in the
shm_open call. So we don't have to do anything special.
Dean
Index: CHANGES
===================================================================
RCS file: /export/home/cvs/apache/src/CHANGES,v
retrieving revision 1.356
diff -u -r1.356 CHANGES
--- CHANGES 1997/07/20 23:45:45 1.356
+++ CHANGES 1997/07/20 23:55:03
@@ -1,4 +1,7 @@
Changes with Apache 1.3
+
+ *) PORT: QNX mmap() support for faster/more reliable scoreboard handling.
+ [Igor N Kovalenko <in...@mail.wplus.net>] PR#683
*) PORT: QNX doesn't have initgroups() which support/suexec.c uses.
[Igor N Kovalenko <in...@mail.wplus.net>]
Index: Configure
===================================================================
RCS file: /export/home/cvs/apache/src/Configure,v
retrieving revision 1.113
diff -u -r1.113 Configure
--- Configure 1997/07/19 09:34:32 1.113
+++ Configure 1997/07/20 23:55:05
@@ -343,13 +343,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*)
Index: conf.h
===================================================================
RCS file: /export/home/cvs/apache/src/conf.h,v
retrieving revision 1.115
diff -u -r1.115 conf.h
--- conf.h 1997/07/16 00:41:20 1.115
+++ conf.h 1997/07/20 23:55:08
@@ -435,6 +435,7 @@
#define HAVE_SYS_SELECT_H
#include <unix.h>
#define JMP_BUF sigjmp_buf
+#define HAVE_MMAP
#elif defined(LYNXOS)
#undef NO_KILLPG
Index: http_main.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_main.c,v
retrieving revision 1.182
diff -u -r1.182 http_main.c
--- http_main.c 1997/07/20 04:05:56 1.182
+++ http_main.c 1997/07/20 23:55:15
@@ -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 -- infoh@mail.wplus.net
+ */
+ 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
}