gnupg/util (ChangeLog dotlock.c)
cvs user dshaw
cvs at cvs.gnupg.org
Thu Jun 9 00:32:12 CEST 2005
Date: Thursday, June 9, 2005 @ 00:54:02
Author: dshaw
Path: /cvs/gnupg/gnupg/util
Modified: ChangeLog dotlock.c
* dotlock.c [HAVE_DOSISH_SYSTEM]: Fix unused function warnings on mingw32.
Noted by Joe Vender.
-----------+
ChangeLog | 5 +++
dotlock.c | 92 ++++++++++++++++++++++++++++--------------------------------
2 files changed, 48 insertions(+), 49 deletions(-)
Index: gnupg/util/ChangeLog
diff -u gnupg/util/ChangeLog:1.190 gnupg/util/ChangeLog:1.191
--- gnupg/util/ChangeLog:1.190 Tue May 31 12:11:00 2005
+++ gnupg/util/ChangeLog Thu Jun 9 00:54:02 2005
@@ -1,3 +1,8 @@
+2005-06-08 David Shaw <dshaw at jabberwocky.com>
+
+ * dotlock.c [HAVE_DOSISH_SYSTEM]: Fix unused function warnings on
+ mingw32. Noted by Joe Vender.
+
2005-05-31 Werner Koch <wk at g10code.com>
* regcomp.c (MB_CUR_MAX) [_WIN32]: Define it only if not defined.
Index: gnupg/util/dotlock.c
diff -u gnupg/util/dotlock.c:1.20 gnupg/util/dotlock.c:1.21
--- gnupg/util/dotlock.c:1.20 Tue May 31 10:38:45 2005
+++ gnupg/util/dotlock.c Thu Jun 9 00:54:02 2005
@@ -1,5 +1,6 @@
/* dotlock.c - dotfile locking
- * Copyright (C) 1998, 1999, 2000, 2001, 2004 Free Software Foundation, Inc.
+ * Copyright (C) 1998, 1999, 2000, 2001, 2004,
+ * 2005 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@@ -52,8 +53,6 @@
static volatile DOTLOCK all_lockfiles;
static int never_lock;
-static int read_lockfile( const char *name );
-
void
disable_dotlock(void)
{
@@ -81,14 +80,14 @@
{
static int initialized;
DOTLOCK h;
- int fd = -1;
- char pidstr[16];
#if !defined (HAVE_DOSISH_SYSTEM)
+ int fd = -1;
+ char pidstr[16];
struct utsname utsbuf;
-#endif
const char *nodename;
const char *dirpart;
int dirpartlen;
+#endif
if( !initialized ) {
atexit( remove_lockfiles );
@@ -235,7 +234,7 @@
#endif
}
-
+#ifndef HAVE_DOSISH_SYSTEM
static int
maybe_deadlock( DOTLOCK h )
@@ -250,6 +249,43 @@
}
/****************
+ * Read the lock file and return the pid, returns -1 on error.
+ */
+static int
+read_lockfile( const char *name )
+{
+ int fd, pid;
+ char pidstr[16];
+
+ if( (fd = open(name, O_RDONLY)) == -1 ) {
+ int e = errno;
+ log_debug("error opening lockfile `%s': %s\n", name, strerror(errno) );
+ errno = e;
+ return -1;
+ }
+ if( read(fd, pidstr, 10 ) != 10 ) { /* Read 10 digits w/o newline */
+ log_debug("error reading lockfile `%s'", name );
+ close(fd);
+ errno = 0;
+ return -1;
+ }
+ pidstr[10] = 0; /* terminate pid string */
+ close(fd);
+ pid = atoi(pidstr);
+#ifndef __riscos__
+ if( !pid || pid == -1 ) {
+#else /* __riscos__ */
+ if( (!pid && riscos_getpid()) || pid == -1 ) {
+#endif /* __riscos__ */
+ log_error("invalid pid %d in lockfile `%s'", pid, name );
+ errno = 0;
+ return -1;
+ }
+ return pid;
+}
+#endif /* !HAVE_DOSISH_SYSTEM */
+
+/****************
* Do a lock on H. A TIMEOUT of 0 returns immediately,
* -1 waits forever (hopefully not), other
* values are timeouts in milliseconds.
@@ -400,48 +436,6 @@
#endif
}
-
-/****************
- * Read the lock file and return the pid, returns -1 on error.
- */
-static int
-read_lockfile( const char *name )
-{
-#if defined (HAVE_DOSISH_SYSTEM)
- return 0;
-#else
- int fd, pid;
- char pidstr[16];
-
- if( (fd = open(name, O_RDONLY)) == -1 ) {
- int e = errno;
- log_debug("error opening lockfile `%s': %s\n", name, strerror(errno) );
- errno = e;
- return -1;
- }
- if( read(fd, pidstr, 10 ) != 10 ) { /* Read 10 digits w/o newline */
- log_debug("error reading lockfile `%s'", name );
- close(fd);
- errno = 0;
- return -1;
- }
- pidstr[10] = 0; /* terminate pid string */
- close(fd);
- pid = atoi(pidstr);
-#ifndef __riscos__
- if( !pid || pid == -1 ) {
-#else /* __riscos__ */
- if( (!pid && riscos_getpid()) || pid == -1 ) {
-#endif /* __riscos__ */
- log_error("invalid pid %d in lockfile `%s'", pid, name );
- errno = 0;
- return -1;
- }
- return pid;
-#endif
-}
-
-
void
remove_lockfiles()
{
More information about the Gnupg-commits
mailing list