Xref: utzoo comp.sys.ibm.pc.rt:1734 comp.mail.sendmail:1750 Path: utzoo!attcan!uunet!comp.vuw.ac.nz!asjl From: Andy.Linton@comp.vuw.ac.nz (Andy Linton) Newsgroups: comp.sys.ibm.pc.rt,comp.mail.sendmail Subject: Re: Problems with Sendmail 5.64 (w/IDA enhancements) on PC/RT (Long) Keywords: GNU-dbm, gdbm, ndbm, flock, lockf, it_doesn't_work, I_hate_RT's Message-ID: <1990Jun27.215556.18748@comp.vuw.ac.nz> Date: 27 Jun 90 21:55:56 GMT References: <1990Jun27.173453.25710@msuinfo.cl.msu.edu> Sender: news@comp.vuw.ac.nz (News Admin) Reply-To: Andy.Linton@comp.vuw.ac.nz Organization: Computer Science Dept, Victoria University, Wellington, NEW ZEALAND Lines: 266 In article <1990Jun27.173453.25710@msuinfo.cl.msu.edu>, gurney@frith.egr.msu.edu (Eddy J. Gurney) writes: |> Well, I've been anxious to get Sendmail 5.64+ installed on my PC RT, and, |> unsurprisingly, I've run into a bunch of problems. |> |> First and foremost, the RT does NOT have an 'flock' function call. It does |> have a 'lockf' function call, which locks certain 'regions' of a file. Per |> a previous request for info on 'lockf', Ed Clarke (clarke@acheron.uucp), |> posted a sample change he made in "alias.c" to use 'lockf' instead of 'flock'. |> I made similar changes to the rest of the 'flock' calls, and those APPEAR to |> have worked. The reason I say "appear" is because the man page for 'lockf' |> says it does not work with standard, buffered I/O, which is what Sendmail |> uses. :-) So I'm not sure if this is actually the correct way to handle the |> situation. I'm wondering if a call to 'fcntl' might not be more appropriate. |> I don't have a man page for it, though, so I'm looking for info on it. (Hint, |> hint...) |> I had this problem with compiling the code on HP-UX 7.0 which I sorted out using these routines. One word of warning though - to obtain an exclusive lock (F_WRLCK) when using 'fcntl' (this is the equivalent of the flock 'LOCK_EX' flag) the file *must* be open for writing. This means that some of the 'open' calls need modified or the type of lock requested must be changed. I have posted the changes I made for HPUX to Paul Pomes at UIUC and he will incorporate them into the distribution there. I could supply such details but we are at the end of a slow link down here and I don't want to clog it. |> . Changed the 'getla()' routine in "conf.c" to also return 0, since I don't |> think the RT has anyway of determining the load average (I don't use this |> feature anyway); removed 'getloadavg.c/.o' from the Makefile I include a patch to make 'getla()' run on HPUX - this may give some pointers on what you need to do. Can someone confirm that the 'getloadavg.c/.o' code is for 4.4BSD? *** /tmp/,RCSt1a21545 Wed Jun 27 12:34:27 1990 --- conf.c Fri Jun 22 13:34:12 1990 *************** *** 24,29 **** --- 24,32 ---- # include # include + # if defined(hpux) + # include + # endif /* hpux */ # include # include "sendmail.h" # include "pathnames.h" *************** *** 128,135 **** /* ** Miscellaneous stuff. */ ! ! int DtableSize = 50; /* max open files; reset in 4.2bsd */ extern int la; /* load average */ /* ** SETDEFAULTS -- set default values --- 131,142 ---- /* ** Miscellaneous stuff. */ ! #ifdef hpux ! #include ! int DtableSize = _NFILE; /* max open files */ ! #else ! int DtableSize = 50;/* max open files; reset in 4.2bsd */ ! #endif extern int la; /* load average */ /* ** SETDEFAULTS -- set default values *************** *** 423,429 **** ** none. */ ! #ifndef sun getla() { --- 430,436 ---- ** none. */ ! #if !defined(sun) && !defined (hpux) getla() { *************** *** 434,446 **** return ((int) (avenrun[0] + 0.5)); } ! #else /* sun */ #include struct nlist Nl[] = { ! { "_avenrun" }, #define X_AVENRUN 0 { 0 }, }; --- 441,457 ---- return ((int) (avenrun[0] + 0.5)); } ! #else /* sun || hpux */ #include struct nlist Nl[] = { ! #ifdef hp9000s800 ! {"avenrun"}, ! #else ! {"_avenrun"}, ! #endif hp9000s800 #define X_AVENRUN 0 { 0 }, }; *************** *** 451,457 **** --- 462,472 ---- return (1); # else /* !sequent */ static int kmem = -1; + # if defined(hpux) + double avenrun[3]; + # else long avenrun[3]; + # endif /* hpux */ extern off_t lseek(); if (kmem < 0) *************** *** 460,468 **** if (kmem < 0) return (-1); (void) ioctl(kmem, (int) FIOCLEX, (char *) 0); ! nlist("/vmunix", Nl); if (Nl[0].n_type == 0) return (-1); } if (lseek(kmem, (off_t) Nl[X_AVENRUN].n_value, 0) == -1 || read(kmem, (char *) avenrun, sizeof(avenrun)) < sizeof(avenrun)) --- 475,495 ---- if (kmem < 0) return (-1); (void) ioctl(kmem, (int) FIOCLEX, (char *) 0); ! #if defined(hpux) ! (void) nlist ("/hp-ux", Nl); ! #else ! (void) nlist ("/vmunix", Nl); ! #endif /* hpux */ if (Nl[0].n_type == 0) + { + /* + * if nlist() has failed we can't use Nl to grope + * about in kmem on subsequent calls to getla() + */ + close (kmem); + kmem = -1; return (-1); + } } if (lseek(kmem, (off_t) Nl[X_AVENRUN].n_value, 0) == -1 || read(kmem, (char *) avenrun, sizeof(avenrun)) < sizeof(avenrun)) *************** *** 470,477 **** /* thank you Ian */ return (-1); } return ((int) (avenrun[0] + FSCALE/2) >> FSHIFT); ! /* return ((int) (avenrun[0] + 0.5)); */ # endif /* sequent */ } --- 497,507 ---- /* thank you Ian */ return (-1); } + # if defined(hpux) + return ((int) (avenrun[0] + 0.5)); + # else return ((int) (avenrun[0] + FSCALE/2) >> FSHIFT); ! # endif /* hpux */ # endif /* sequent */ } -- #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh 'flock.c' <<'END_OF_FILE' X X#include X#include X#include "flock.h" /* defines normally in */ X Xflock(fd, operation) Xint fd, operation; X{ X int op, ret; X struct flock arg; X extern int errno; X X op = (LOCK_NB & operation) ? F_SETLK : F_SETLKW; X X arg.l_type = (LOCK_EX & operation) ? F_WRLCK : X (LOCK_SH & operation) ? F_RDLCK : F_UNLCK; X arg.l_whence = 0; X arg.l_start = 0; X arg.l_len = 0; X arg.l_pid = 0; X X if ((ret = fcntl(fd, op, &arg)) == -1) { X if (errno == EACCES || errno == EAGAIN) X errno = EWOULDBLOCK; X } X return (ret); X} END_OF_FILE if test 551 -ne `wc -c <'flock.c'`; then echo shar: \"'flock.c'\" unpacked with wrong size! fi # end of 'flock.c' fi if test -f 'flock.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'flock.h'\" else echo shar: Extracting \"'flock.h'\" \(288 characters\) sed "s/^X//" >'flock.h' <<'END_OF_FILE' X/* These definitions are in on BSD 4.3 */ X/* X * Flock call. X */ X#define LOCK_SH 1 /* shared lock */ X#define LOCK_EX 2 /* exclusive lock */ X#define LOCK_NB 4 /* don't block when locking */ X#define LOCK_UN 8 /* unlock */ END_OF_FILE if test 288 -ne `wc -c <'flock.h'`; then echo shar: \"'flock.h'\" unpacked with wrong size! fi # end of 'flock.h' fi echo shar: End of shell archive. exit 0