summaryrefslogtreecommitdiffstats
path: root/contrib/opie/libopie/lock.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/opie/libopie/lock.c')
-rw-r--r--contrib/opie/libopie/lock.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/contrib/opie/libopie/lock.c b/contrib/opie/libopie/lock.c
index bd92607..0f666a6 100644
--- a/contrib/opie/libopie/lock.c
+++ b/contrib/opie/libopie/lock.c
@@ -1,7 +1,7 @@
/* lock.c: The opielock() library function.
%%% portions-copyright-cmetz-96
-Portions of this software are Copyright 1996-1999 by Craig Metz, All Rights
+Portions of this software are Copyright 1996-1998 by Craig Metz, All Rights
Reserved. The Inner Net License Version 2 applies to these portions of
the software.
You should have received a copy of the license with this software. If
@@ -14,7 +14,6 @@ License Agreement applies to this software.
History:
- Modified by cmetz for OPIE 2.4. Use snprintf.
Modified by cmetz for OPIE 2.31. Put locks in a separate dir.
Bug fixes.
Modified by cmetz for OPIE 2.3. Do refcounts whether or not we
@@ -28,6 +27,8 @@ License Agreement applies to this software.
error return values. Check open() return value properly.
Avoid NULL.
Created at NRL for OPIE 2.2 from opiesubr2.c
+
+$FreeBSD$
*/
#include "opie_cfg.h"
#if HAVE_STRING_H
@@ -50,12 +51,17 @@ License Agreement applies to this software.
#endif /* !HAVE_LSTAT */
int __opie_lockrefcount = 0;
+static int do_atexit = 1;
+VOIDRET opiedisableaeh FUNCTION_NOARGS
+{
+ do_atexit = 0;
+}
#if USER_LOCKING
char *__opie_lockfilename = (char *)0;
/* atexit() handler for opielock() */
-static VOIDRET opieunlockaeh FUNCTION_NOARGS
+VOIDRET opieunlockaeh FUNCTION_NOARGS
{
if (__opie_lockfilename) {
__opie_lockrefcount = 0;
@@ -195,9 +201,7 @@ int opielock FUNCTION((principal), char *principal)
if (!S_ISREG(statbuf[0].st_mode) || (statbuf[0].st_mode != statbuf[1].st_mode) || (statbuf[0].st_ino != statbuf[1].st_ino))
goto lockret;
- if (snprintf(buffer, sizeof(buffer), "%d\n%d\n", getpid(), time(0)) >= sizeof(buffer))
- goto lockret;
-
+ sprintf(buffer, "%d\n%d\n", getpid(), time(0));
i = strlen(buffer) + 1;
if (lseek(fh, 0, SEEK_SET)) {
close(fh);
@@ -230,7 +234,8 @@ int opielock FUNCTION((principal), char *principal)
__opie_lockrefcount++;
rval = 0;
- atexit(opieunlockaeh);
+ if (do_atexit)
+ atexit(opieunlockaeh);
lockret:
if (fh >= 0)
OpenPOWER on IntegriCloud