Article View: news.software.nntp
Article #29014INN 2.0 problems with HP/UX, and a fix
From: Heath Kehoe
Date: Wed, 10 Jun 1998 00:00
Date: Wed, 10 Jun 1998 00:00
332 lines
11262 bytes
11262 bytes
(I'm sending this message to inn-patches@vix.com, and also
posting it to news.software.nntp)
While running configure for INN 2.0 on an HP/UX 10.20 system, I
noticed that the mmap test failed. This is incorrect; the HP
mmap should work fine with INN. So I investigated, and found
that autoconf's mmap test tries a specific usage of mmap that
HP/UX does not like (namely, it tries mmap with the MAP_FIXED
flag). INN does not use MAP_FIXED. In addition, the autoconf
test verifies that MAP_PRIVATE works properly, which is also
useless since INN always uses MAP_SHARED.
So, I've modified configure.in to replace AC_FUNC_MMAP with
a version of the mmap test modified to use MAP_SHARED instead
of MAP_FIXED|MAP_PRIVATE.
In addition, I added a similar test, that can determine how
MMAP_SYNC should be set. I've tried this on HP/UX and linux,
and got correct results (HP needs MMAP_SYNC=DO, and linux
does not).
The enclosed patch includes the modifications to configure.in
and config.scoreboard; and also includes a fix to a minor,
HPUX-specific problem in nnrpd.c
--Heath
diff -rc ../inn-2.0/configure.in ./configure.in
*** ../inn-2.0/configure.in Mon Jun 8 10:06:15 1998
--- ./configure.in Wed Jun 10 16:08:08 1998
***************
*** 358,364 ****
dnl Checks for library functions.
AC_PROG_GCC_TRADITIONAL
AC_FUNC_MEMCMP
- AC_FUNC_MMAP
AC_FUNC_SETVBUF_REVERSED
AC_TYPE_SIGNAL
AC_SUBST(ac_cv_type_signal)
--- 358,363 ----
***************
*** 372,377 ****
--- 371,596 ----
AC_CHECK_FUNCS(strrchr strspn strstr symlink sysconf syslog ulimit)
AC_CHECK_FUNCS(waitpid)
+
+ dnl This portion is similar to what AC_FUNC_MMAP does, only
+ dnl it tests shared, non-fixed mmaps.
+
+ AC_CHECK_FUNCS(getpagesize)
+ AC_CACHE_CHECK(for working mmap, ac_cv_func_mmap_shared,
+ [AC_TRY_RUN([
+ /* test shared mmap */
+ #include <sys/types.h>
+ #include <fcntl.h>
+ #include <sys/mman.h>
+
+ /* This mess was copied from the GNU getpagesize.h. */
+ #ifndef HAVE_GETPAGESIZE
+ # ifdef HAVE_UNISTD_H
+ # include <unistd.h>
+ # endif
+
+ /* Assume that all systems that can run configure have sys/param.h. */
+ # ifndef HAVE_SYS_PARAM_H
+ # define HAVE_SYS_PARAM_H 1
+ # endif
+
+ # ifdef _SC_PAGESIZE
+ # define getpagesize() sysconf(_SC_PAGESIZE)
+ # else /* no _SC_PAGESIZE */
+ # ifdef HAVE_SYS_PARAM_H
+ # include <sys/param.h>
+ # ifdef EXEC_PAGESIZE
+ # define getpagesize() EXEC_PAGESIZE
+ # else /* no EXEC_PAGESIZE */
+ # ifdef NBPG
+ # define getpagesize() NBPG * CLSIZE
+ # ifndef CLSIZE
+ # define CLSIZE 1
+ # endif /* no CLSIZE */
+ # else /* no NBPG */
+ # ifdef NBPC
+ # define getpagesize() NBPC
+ # else /* no NBPC */
+ # ifdef PAGESIZE
+ # define getpagesize() PAGESIZE
+ # endif /* PAGESIZE */
+ # endif /* no NBPC */
+ # endif /* no NBPG */
+ # endif /* no EXEC_PAGESIZE */
+ # else /* no HAVE_SYS_PARAM_H */
+ # define getpagesize() 8192 /* punt totally */
+ # endif /* no HAVE_SYS_PARAM_H */
+ # endif /* no _SC_PAGESIZE */
+
+ #endif /* no HAVE_GETPAGESIZE */
+
+ #ifdef __cplusplus
+ extern "C" { void *malloc(unsigned); }
+ #else
+ char *malloc();
+ #endif
+
+ int
+ main()
+ {
+ char *data, *data2;
+ int i, pagesize;
+ int fd;
+
+ pagesize = getpagesize();
+
+ /*
+ * First, make a file with some known garbage in it.
+ */
+ data = malloc(pagesize);
+ if (!data)
+ exit(1);
+ for (i = 0; i < pagesize; ++i)
+ *(data + i) = rand();
+ umask(0);
+ fd = creat("conftestmmaps", 0600);
+ if (fd < 0)
+ exit(1);
+ if (write(fd, data, pagesize) != pagesize)
+ exit(1);
+ close(fd);
+
+ /*
+ * Next, try to mmap the file. If we can,
+ * also make sure that we see the same garbage.
+ */
+ fd = open("conftestmmaps", O_RDWR);
+ if (fd < 0)
+ exit(1);
+ if (! (data2 = mmap((void*)0, pagesize, PROT_READ | PROT_WRITE,
+ MAP_SHARED, fd, 0L)) )
+ exit(1);
+ for (i = 0; i < pagesize; ++i)
+ if (*(data + i) != *(data2 + i))
+ exit(1);
+
+ close(fd);
+ unlink("conftestmmaps");
+ exit(0);
+ }
+ ], ac_cv_func_mmap_shared=yes, ac_cv_func_mmap_shared=no,
+ ac_cv_func_mmap_shared=no)])
+ if test $ac_cv_func_mmap_shared = yes; then
+ AC_DEFINE(HAVE_MMAP)
+ fi
+
+ AC_CACHE_CHECK(whether msync is needed, ac_cv_func_need_msync,
+ [AC_TRY_RUN([
+ /* test shared mmap (msync) */
+ #include <sys/types.h>
+ #include <fcntl.h>
+ #include <sys/mman.h>
+
+ /* This mess was copied from the GNU getpagesize.h. */
+ #ifndef HAVE_GETPAGESIZE
+ # ifdef HAVE_UNISTD_H
+ # include <unistd.h>
+ # endif
+
+ /* Assume that all systems that can run configure have sys/param.h. */
+ # ifndef HAVE_SYS_PARAM_H
+ # define HAVE_SYS_PARAM_H 1
+ # endif
+
+ # ifdef _SC_PAGESIZE
+ # define getpagesize() sysconf(_SC_PAGESIZE)
+ # else /* no _SC_PAGESIZE */
+ # ifdef HAVE_SYS_PARAM_H
+ # include <sys/param.h>
+ # ifdef EXEC_PAGESIZE
+ # define getpagesize() EXEC_PAGESIZE
+ # else /* no EXEC_PAGESIZE */
+ # ifdef NBPG
+ # define getpagesize() NBPG * CLSIZE
+ # ifndef CLSIZE
+ # define CLSIZE 1
+ # endif /* no CLSIZE */
+ # else /* no NBPG */
+ # ifdef NBPC
+ # define getpagesize() NBPC
+ # else /* no NBPC */
+ # ifdef PAGESIZE
+ # define getpagesize() PAGESIZE
+ # endif /* PAGESIZE */
+ # endif /* no NBPC */
+ # endif /* no NBPG */
+ # endif /* no EXEC_PAGESIZE */
+ # else /* no HAVE_SYS_PARAM_H */
+ # define getpagesize() 8192 /* punt totally */
+ # endif /* no HAVE_SYS_PARAM_H */
+ # endif /* no _SC_PAGESIZE */
+
+ #endif /* no HAVE_GETPAGESIZE */
+
+ #ifdef __cplusplus
+ extern "C" { void *malloc(unsigned); }
+ #else
+ char *malloc();
+ #endif
+
+ int
+ main()
+ {
+ char *data, *data2, *data3;
+ int i, pagesize;
+ int fd, rval;
+
+ pagesize = getpagesize();
+
+ /*
+ * First, make a file with some known garbage in it.
+ */
+ data = malloc(pagesize);
+ if (!data)
+ exit(1);
+ for (i = 0; i < pagesize; ++i)
+ *(data + i) = rand();
+ umask(0);
+ fd = creat("conftestmmapm", 0600);
+ if (fd < 0)
+ exit(1);
+ if (write(fd, data, pagesize) != pagesize)
+ exit(1);
+ close(fd);
+
+ /*
+ * Next, try to mmap the file.
+ */
+ fd = open("conftestmmapm", O_RDWR);
+ if (fd < 0)
+ exit(1);
+ if (! (data2 = mmap((void*)0, pagesize, PROT_READ | PROT_WRITE,
+ MAP_SHARED, fd, 0L)) )
+ exit(1);
+
+ /*
+ * Finally, see if changes to the mapped area automatically
+ * percolate back to the file as seen by read().
+ * I.E., msync is not needed
+ */
+ rval = 0;
+ for (i = 0; i < pagesize; ++i)
+ *(data2 + i) = *(data2 + i) + 1;
+ data3 = malloc(pagesize);
+ if (!data3)
+ exit(1);
+ if (read(fd, data3, pagesize) != pagesize)
+ exit(1);
+ for (i = 0; i < pagesize; ++i)
+ if (*(data + i) != *(data3 + i))
+ rval = 1;
+ close(fd);
+ unlink("conftestmmapm");
+ exit(rval);
+ }
+ ], ac_cv_func_need_msync=yes, ac_cv_func_need_msync=no,
+ ac_cv_func_need_msync=no)])
+
dnl
if test $ac_cv_lib_regex_regexec = no; then
AC_CHECK_FUNC(regexec,[DO_KEYWORDS=DO],[DO_KEYWORDS=DONT])
***************
*** 629,635 ****
YN_to_cv_subst(ac_cv_type_off_t, ac_cv_subst_lseekval, off_t, long)
YN_to_cv_subst(ac_cv_func_getrusage, ac_cv_subst_res_style, RUSAGE, TIMES)
YN_to_cv_subst(ac_cv_header_time, ac_cv_subst_need_time, DO, DONT)
! YN_to_cv_subst(ac_cv_func_mmap_fixed_mapped, ac_cv_subst_act_style, MMAP, READ)
dnl Missing sources
MISSING_MAN=""
--- 848,855 ----
YN_to_cv_subst(ac_cv_type_off_t, ac_cv_subst_lseekval, off_t, long)
YN_to_cv_subst(ac_cv_func_getrusage, ac_cv_subst_res_style, RUSAGE, TIMES)
YN_to_cv_subst(ac_cv_header_time, ac_cv_subst_need_time, DO, DONT)
! YN_to_cv_subst(ac_cv_func_mmap_shared, ac_cv_subst_act_style, MMAP, READ)
! YN_to_cv_subst(ac_cv_func_need_msync, ac_cv_subst_mmap_sync, DO, DONT)
dnl Missing sources
MISSING_MAN=""
diff -rc ../inn-2.0/config/config.scoreboard ./config/config.scoreboard
*** ../inn-2.0/config/config.scoreboard Mon Jun 8 10:06:15 1998
--- ./config/config.scoreboard Wed Jun 10 15:53:34 1998
***************
*** 149,156 ****
[IN1.7=@6][WDF=autoconf][WOR=no][P=high]
||## Should we msync when using mmap? Pick DO or DONT. Useful
||## with some slightly broken mmap implementations. (like HPUX and BSD/OS).
||#### =()<MMAP_SYNC @<MMAP_SYNC>@>()=
! ||MMAP_SYNC DONT
[IN1.7=@6][WDF=confparam][WOR=no][P=low]
||## Do clients use our NNTP-server-open routine, or the one in NNTP?
||## INND is nicer, but you must install inn.conf files everywhere; NNTP
--- 149,157 ----
[IN1.7=@6][WDF=autoconf][WOR=no][P=high]
||## Should we msync when using mmap? Pick DO or DONT. Useful
||## with some slightly broken mmap implementations. (like HPUX and BSD/OS).
+ ||##[autoconf]
||#### =()<MMAP_SYNC @<MMAP_SYNC>@>()=
! ||MMAP_SYNC @ac_cv_subst_mmap_sync@
[IN1.7=@6][WDF=confparam][WOR=no][P=low]
||## Do clients use our NNTP-server-open routine, or the one in NNTP?
||## INND is nicer, but you must install inn.conf files everywhere; NNTP
diff -rc ../inn-2.0/nnrpd/nnrpd.c ./nnrpd/nnrpd.c
*** ../inn-2.0/nnrpd/nnrpd.c Mon Jun 8 10:06:15 1998
--- ./nnrpd/nnrpd.c Wed Jun 10 12:28:30 1998
***************
*** 283,288 ****
--- 283,289 ----
union pstun un;
(void)sprintf(buff, "(nnrpd) %s %s", ClientHost, what);
+ un.pst_command = buff;
(void)pstat(PSTAT_SETCMD, un, strlen(buff), 0, 0);
#endif /* defined(HPUX) */
#endif /* defined(HAVE_SETPROCTITLE) */
--
Heath A. Kehoe | "Education is the true foundation of civil liberty."
System/Network Admin | --James Madison
hakehoe@norand.com |
Technical Details
Message-ID:
<slrn6nu107.mtm.hakehoe@darkside.norand.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mailShow Full Headers
Complete Article Headers
Message-ID: <slrn6nu107.mtm.hakehoe@darkside.norand.com> Subject: INN 2.0 problems with HP/UX, and a fix Date: Wed, 10 Jun 1998 00:00:00 +0000 From: hakehoe@darkside.norand.com (Heath Kehoe) Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail X-Deja-AN: 361512378 Organization: Norand Corporation Newsgroups: news.software.nntp