Here it goes again. Since last version was not quite welcomed, I'll defend it in advance. First, it fixes the undefined 'NOFD' constant. Of course, I could also make it totally QNX-specific, but I'd hate to pollute code with #ifdef SOME_OS unless necessary and I don't think any of you here would like that either. After all, that is the reason to have OS-specific sections in one header which would turn on or off appropriate 'features'.
One of the things objected in last version was addition of MAP_ANON clause
in PTHREAD_SERIALIZED_ACCEPT code. As I said, I could agree to remove that,
but ... the PTHREAD_SERIALIZED_ACCEPT is OS-specific feature to begin with,
so it would only matter if it is enabled. Looking at 1.3.22 code, no
platform actually defines USE_PTHREAD_SERIALIZED_ACCEPT by default and only
Solaris, HP-UX (commented out) and AIX appear to even mention it. And the
implementation appears to be Solaris-specific, in fact. That makes me think
I am not hurting anyone by adding MAP_ANON version, I would actually guess
it might make some platforms be able to use that code. And it still works on
Solaris (2.8 has MAP_ANON and it works, 2.5 has no MAP_ANON, so it still
works old way) and saves unnecessary open() and close() calls.
I don't want to waste any more of anyone's time discussing this, the issue
is not worth it. If that part of patch is still unaceptable, I am fine
without it.
Another non-specific change is addition of USE_POSIX_SCOREBOARD condition to
the 'optimize timeouts'. That is because 1) it is logical, since it is same
thing as USE_MMAP_SCOREBOARD & USE_SHMGET_SCOREBOARD and 2) I wrote the
USE_POSIX_SCOREBOARD code.
regards,
- igor
diff -ru apache_1.3.22/src/Configure apache_1.3.22/src/Configure
--- apache_1.3.22/src/Configure Mon Oct 8 14:59:36 2001
+++ apache_1.3.22/src/Configure Thu Oct 18 00:21:27 2001
@@ -554,6 +554,11 @@
CFLAGS="$CFLAGS -DQNX -mf -3"
LIBS="$LIBS -N128k -lsocket -lunix"
DEF_WANTHSREGEX=yes
+ ;;
+ *-*-qnx6)
+ OS='NTO'
+ CFLAGS="$CFLAGS -DNTO"
+ LIBS="$LIBS -lm -lsocket"
;;
*-isc4*)
OS='ISC 4'
@@ -1076,6 +1081,14 @@
LDFLAGS_SHLIB='-b -a archive'
LDFLAGS_MOD_SHLIB=$LDFLAGS_SHLIB
;;
+ *-*-qnx6*)
+ LD_SHLIB="gcc"
+ CFLAGS_SHLIB="-fPIC"
+ LDFLAGS_SHLIB="-shared"
+ LDFLAGS_MOD_SHLIB=$LDFLAGS_SHLIB
+ LDFLAGS_SHLIB_EXPORT="-Wl,-E"
+ SHLIB_SUFFIX_DEPTH=0
+ ;;
*-linux1)
CFLAGS_SHLIB="-fpic"
LDFLAGS_SHLIB="-Bshareable"
diff -ru apache_1.3.22/src/helpers/GuessOS apache_1.3.22/src/helpers/GuessOS
--- apache_1.3.22/src/helpers/GuessOS Mon Oct 8 09:49:33 2001
+++ apache_1.3.22/src/helpers/GuessOS Thu Oct 18 00:30:28 2001
@@ -181,12 +181,22 @@
echo "${MACHINE}-tandem-oss"; exit 0;
;;
- QNX:*)
- if [ "$VERSION" -gt 422 ]; then
- echo "${MACHINE}-qssl-qnx32"
- else
- echo "${MACHINE}-qssl-qnx"
+ *nto:* | QNX:*)
+ if test "${MACHINE}" = "x86pc" || test "${MACHINE}" = "PCI" ; then
+ MACHINE="pc"
fi
+ case $RELEASE in
+ [0-9]*)
+ echo "${MACHINE}-qssl-qnx6"
+ ;;
+ [A-Z]*)
+ if [ "$VERSION" -gt 422 ]; then
+ echo "${MACHINE}-qssl-qnx32"
+ else
+ echo "${MACHINE}-qssl-qnx"
+ fi
+ ;;
+ esac
exit 0
;;
diff -ru apache_1.3.22/src/include/ap_config.h
apache_1.3.22/src/include/ap_config.h
--- apache_1.3.22/src/include/ap_config.h Mon Oct 8 09:49:33 2001
+++ apache_1.3.22/src/include/ap_config.h Sun Oct 21 00:15:14 2001
@@ -745,6 +745,36 @@
#define NET_SIZE_T socklen_t
#endif
+#elif defined(NTO)
+
+#define HAVE_MMAP 1
+#define HAVE_GMTOFF 1
+#define HAVE_SYSLOG 1
+
+#define USE_MMAP_SCOREBOARD
+#define USE_MMAP_FILES 1
+#define USE_PTHREAD_SERIALIZED_ACCEPT
+
+#undef MAP_TMPFILE
+#undef NO_TIMES
+
+/* needs prototypes for execXX */
+#define NEED_PROCESS_H
+
+/*
+ Careful here.
+ Things have changed a lot between 6.0 and 6.1
+ We'll assume 6.1+ is default
+*/
+/* loader does not support #! before 6.1 */
+/* #define NEED_HASHBANG_EMUL */
+/* kernel does not implement getrlimit/setrlimit before 6.1 */
+/* #undef HAVE_SYS_RESOURCE_H */
+/* tiny stack does not implement SO_LINGER */
+/* #undef USE_SO_LINGER */
+/* lingering close is broken with tiny TCP stack */
+/* #define NO_LINGCLOSE */
+
#elif defined(QNX)
#ifndef crypt
char *crypt(const char *pw, const char *salt);
@@ -1156,7 +1186,7 @@
#undef NSIG
#endif
#include <errno.h>
-#if !defined(QNX) && !defined(CONVEXOS11) && !defined(NEXT) &&
!defined(TPF) && !defined(NETWARE) && !defined(MPE)
+#if !defined(QNX) && !defined(NTO) && !defined(CONVEXOS11) &&
!defined(NEXT) && !defined(TPF) && !defined(NETWARE) && !defined(MPE)
#include <memory.h>
#endif
diff -ru apache_1.3.22/src/include/httpd.h apache_1.3.22/src/include/httpd.h
--- apache_1.3.22/src/include/httpd.h Mon Oct 8 21:56:05 2001
+++ apache_1.3.22/src/include/httpd.h Thu Oct 18 01:06:10 2001
@@ -1189,7 +1189,7 @@
* also not using a scoreboard file
*/
#if !defined (MULTITHREAD) && \
- (defined (USE_MMAP_SCOREBOARD) || defined (USE_SHMGET_SCOREBOARD))
+ (defined (USE_MMAP_SCOREBOARD) || defined (USE_SHMGET_SCOREBOARD) ||
defined(USE_POSIX_SCOREBOARD))
#define OPTIMIZE_TIMEOUTS
#endif
diff -ru apache_1.3.22/src/main/http_core.c
apache_1.3.22/src/main/http_core.c
--- apache_1.3.22/src/main/http_core.c Tue Sep 4 12:15:15 2001
+++ apache_1.3.22/src/main/http_core.c Sun Nov 4 05:27:38 2001
@@ -3666,8 +3666,18 @@
&& (!r->header_only || (d->content_md5 & 1))) {
/* we need to protect ourselves in case we die while we've got the
* file mmapped */
+#ifdef NTO
+ /*
+ MAP_NOSYNCFILE is required for mmap() on regular files,
+ MAP_ELF is just a workaround for a bug in 6.1 (fails on MAP_PRIVATE)
+ It appears to give some 10% performance boost nevertheless
+ */
+ mm = mmap(NULL, r->finfo.st_size, PROT_READ,
+ MAP_PRIVATE|MAP_NOSYNCFILE|MAP_ELF, fileno(f), 0);
+#else
mm = mmap(NULL, r->finfo.st_size, PROT_READ, MAP_PRIVATE,
fileno(f), 0);
+#endif
if (mm == (caddr_t)-1) {
ap_log_rerror(APLOG_MARK, APLOG_CRIT, r,
"default_handler: mmap failed: %s", r->filename);
diff -ru apache_1.3.22/src/main/http_main.c
apache_1.3.22/src/main/http_main.c
--- apache_1.3.22/src/main/http_main.c Fri Oct 5 20:21:11 2001
+++ apache_1.3.22/src/main/http_main.c Wed Nov 14 01:35:24 2001
@@ -611,6 +611,8 @@
* on Solaris. Note that pthread mutexes are *NOT* released when a task
* dies ... the task has to free it itself. So we block signals and
* try to be nice about releasing the mutex.
+ *
+ * --- This works on QNX6 as well, even faster perhaps ---
*/
#include <pthread.h>
@@ -645,8 +647,20 @@
static void accept_mutex_init_pthread(pool *p)
{
pthread_mutexattr_t mattr;
- int fd;
+#ifdef MAP_ANON
+#ifndef NOFD
+#define NOFD -1
+#endif
+ accept_mutex = (pthread_mutex_t *) mmap((caddr_t) 0,
sizeof(*accept_mutex),
+ PROT_READ | PROT_WRITE, MAP_ANON|MAP_SHARED, NOFD, 0);
+ if (accept_mutex == (void *) (caddr_t) - 1) {
+ perror("mmap");
+ exit(APEXIT_INIT);
+ }
+#else
+ int fd;
+
fd = open("/dev/zero", O_RDWR);
if (fd == -1) {
perror("open(/dev/zero)");
@@ -659,6 +673,7 @@
exit(APEXIT_INIT);
}
close(fd);
+#endif
if ((errno = pthread_mutexattr_init(&mattr))) {
perror("pthread_mutexattr_init");
exit(APEXIT_INIT);
@@ -2042,30 +2057,13 @@
/*
* POSIX 1003.4 style
*
- * Note 1:
- * As of version 4.23A, shared memory in QNX must reside under /dev/shmem,
- * where no subdirectories allowed.
+ * This code is only used by QNX4 probably, and from version 4.25
+ * QNX4 can actually use USE_MMAP_SCOREBOARD. So this is only still
+ * useful if you're stuck with one of earlier versions. Otherwise
+ * just define USE_MMAP_SCOREBOARD in QNX section of Configure.
*
- * 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 USE_MMAP_SCOREBOARD in QNX section
- * of ap_config.h
- *
- * June 5, 1997,
- * Igor N. Kovalenko -- [EMAIL PROTECTED]
+ * Oct 18, 2001,
+ * Igor Kovalenko -- [EMAIL PROTECTED]
*/
static void cleanup_shared_mem(void *d)
diff -ru apache_1.3.22/src/modules/standard/mod_mime_magic.c
apache_1.3.22/src/modules/standard/mod_mime_magic.c
--- apache_1.3.22/src/modules/standard/mod_mime_magic.c Wed Oct 3 23:55:01
2001
+++ apache_1.3.22/src/modules/standard/mod_mime_magic.c Thu Oct 18 02:11:56
2001
@@ -255,7 +255,7 @@
static int match(request_rec *, unsigned char *, int);
static int mget(request_rec *, union VALUETYPE *, unsigned char *,
struct magic *, int);
-static int mcheck(request_rec *, union VALUETYPE *, struct magic *);
+static int ap_mcheck(request_rec *, union VALUETYPE *, struct magic *);
static void mprint(request_rec *, union VALUETYPE *, struct magic *);
static int uncompress(request_rec *, int,
@@ -1600,7 +1600,7 @@
/* check if main entry matches */
if (!mget(r, &p, s, m, nbytes) ||
- !mcheck(r, &p, m)) {
+ !ap_mcheck(r, &p, m)) {
struct magic *m_cont;
/*
@@ -1671,7 +1671,7 @@
cont_level = m->cont_level;
}
if (mget(r, &p, s, m, nbytes) &&
- mcheck(r, &p, m)) {
+ ap_mcheck(r, &p, m)) {
/*
* This continuation matched. Print its message, with a
* blank before it if the previous item printed and this
@@ -1845,7 +1845,7 @@
return 1;
}
-static int mcheck(request_rec *r, union VALUETYPE *p, struct magic *m)
+static int ap_mcheck(request_rec *r, union VALUETYPE *p, struct magic *m)
{
register unsigned long l = m->value.l;
register unsigned long v;
@@ -1898,7 +1898,7 @@
default:
/* bogosity, pretend that it just wasn't a match */
ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_ERR, r,
- MODNAME ": invalid type %d in mcheck().", m->type);
+ MODNAME ": invalid type %d in ap_mcheck().", m->type);
return 0;
}
@@ -1983,7 +1983,7 @@
/* bogosity, pretend it didn't match */
matched = 0;
ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_ERR, r,
- MODNAME ": mcheck: can't happen: invalid relation %d.",
+ MODNAME ": ap_mcheck: can't happen: invalid relation %d.",
m->reln);
break;
}
diff -ru apache_1.3.22/src/support/htdigest.c
apache_1.3.22/src/support/htdigest.c
--- apache_1.3.22/src/support/htdigest.c Wed Jul 25 09:08:04 2001
+++ apache_1.3.22/src/support/htdigest.c Thu Oct 18 01:46:57 2001
@@ -73,7 +73,7 @@
#endif
#include "ap.h"
#include "ap_md5.h"
-#if defined(MPE) || defined(QNX) || defined(WIN32) || defined(__TANDEM) ||
defined(OS390) || defined(BEOS) || defined(BONE)
+#if defined(MPE) || defined(QNX) || defined(NTO) || defined(WIN32) ||
defined(__TANDEM) || defined(OS390) || defined(BEOS) || defined(BONE)
#include <signal.h>
#else
#include <sys/signal.h>
diff -ru apache_1.3.22/src/support/suexec.c
apache_1.3.22/src/support/suexec.c
--- apache_1.3.22/src/support/suexec.c Thu Mar 8 12:11:43 2001
+++ apache_1.3.22/src/support/suexec.c Thu Oct 18 01:54:14 2001
@@ -95,11 +95,11 @@
/*
***********************************************************************
- * There is no initgroups() in QNX, so I believe this is safe :-)
- * Use cc -osuexec -3 -O -mf -DQNX suexec.c to compile.
+ * There is no initgroups() in QNX4 (but there is in QNX6)
+ * On QNX4 compile with cc -osuexec -3 -O -mf -DQNX suexec.c
*
- * May 17, 1997.
- * Igor N. Kovalenko -- [EMAIL PROTECTED]
+ * Oct 18, 2001.
+ * Igor Kovalenko -- [EMAIL PROTECTED]
***********************************************************************
*/
apache-qnx6.diff
Description: Binary data
