Article View: comp.sys.ibm.pc.rt
Article #763Re: Problems with Sendmail 5.64 (w/IDA enhancements) on PC/RT (Long)
From: Andy Linton
Date: Wed, 27 Jun 1990 21:55
Date: Wed, 27 Jun 1990 21:55
266 lines
8155 bytes
8155 bytes
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 <sys/ioctl.h>
# include <sys/param.h>
+ # if defined(hpux)
+ # include <sgtty.h>
+ # endif /* hpux */
# include <pwd.h>
# 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 <stdio.h>
! 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 <nlist.h>
struct nlist Nl[] =
{
! { "_avenrun" },
#define X_AVENRUN 0
{ 0 },
};
--- 441,457 ----
return ((int) (avenrun[0] + 0.5));
}
! #else /* sun || hpux */
#include <nlist.h>
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 <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of shell archive."
# Contents: flock.c flock.h
# Wrapped by mark@the-taj.comp.vuw.ac.nz on Tue Jun 20 21:37:36 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'flock.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'flock.c'\"
else
echo shar: Extracting \"'flock.c'\" \(551 characters\)
sed "s/^X//" >'flock.c' <<'END_OF_FILE'
X
X#include <fcntl.h>
X#include <errno.h>
X#include "flock.h" /* defines normally in <sys/file.h> */
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 <sys/file.h> 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
Technical Details
Message-ID:
<1990Jun27.215556.18748@comp.vuw.ac.nz>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!comp.vuw.ac.nz!asjlReferences:
<1990Jun27.173453.25710@msuinfo.cl.msu.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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