mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-23 10:29:58 +01:00
* dotlock.c [HAVE_DOSISH_SYSTEM]: Fix unused function warnings on mingw32.
Noted by Joe Vender.
This commit is contained in:
parent
1b07e3723e
commit
dddcb6d90c
@ -1,3 +1,8 @@
|
|||||||
|
2005-06-08 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
|
* dotlock.c [HAVE_DOSISH_SYSTEM]: Fix unused function warnings on
|
||||||
|
mingw32. Noted by Joe Vender.
|
||||||
|
|
||||||
2005-05-31 Werner Koch <wk@g10code.com>
|
2005-05-31 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
* regcomp.c (MB_CUR_MAX) [_WIN32]: Define it only if not defined.
|
* regcomp.c (MB_CUR_MAX) [_WIN32]: Define it only if not defined.
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/* dotlock.c - dotfile locking
|
/* 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.
|
* This file is part of GnuPG.
|
||||||
*
|
*
|
||||||
@ -52,8 +53,6 @@ struct dotlock_handle {
|
|||||||
static volatile DOTLOCK all_lockfiles;
|
static volatile DOTLOCK all_lockfiles;
|
||||||
static int never_lock;
|
static int never_lock;
|
||||||
|
|
||||||
static int read_lockfile( const char *name );
|
|
||||||
|
|
||||||
void
|
void
|
||||||
disable_dotlock(void)
|
disable_dotlock(void)
|
||||||
{
|
{
|
||||||
@ -81,14 +80,14 @@ create_dotlock( const char *file_to_lock )
|
|||||||
{
|
{
|
||||||
static int initialized;
|
static int initialized;
|
||||||
DOTLOCK h;
|
DOTLOCK h;
|
||||||
int fd = -1;
|
|
||||||
char pidstr[16];
|
|
||||||
#if !defined (HAVE_DOSISH_SYSTEM)
|
#if !defined (HAVE_DOSISH_SYSTEM)
|
||||||
|
int fd = -1;
|
||||||
|
char pidstr[16];
|
||||||
struct utsname utsbuf;
|
struct utsname utsbuf;
|
||||||
#endif
|
|
||||||
const char *nodename;
|
const char *nodename;
|
||||||
const char *dirpart;
|
const char *dirpart;
|
||||||
int dirpartlen;
|
int dirpartlen;
|
||||||
|
#endif
|
||||||
|
|
||||||
if( !initialized ) {
|
if( !initialized ) {
|
||||||
atexit( remove_lockfiles );
|
atexit( remove_lockfiles );
|
||||||
@ -235,7 +234,7 @@ destroy_dotlock ( DOTLOCK h )
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef HAVE_DOSISH_SYSTEM
|
||||||
|
|
||||||
static int
|
static int
|
||||||
maybe_deadlock( DOTLOCK h )
|
maybe_deadlock( DOTLOCK h )
|
||||||
@ -249,6 +248,43 @@ maybe_deadlock( DOTLOCK h )
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************
|
||||||
|
* 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,
|
* Do a lock on H. A TIMEOUT of 0 returns immediately,
|
||||||
* -1 waits forever (hopefully not), other
|
* -1 waits forever (hopefully not), other
|
||||||
@ -400,48 +436,6 @@ release_dotlock( DOTLOCK h )
|
|||||||
#endif
|
#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
|
void
|
||||||
remove_lockfiles()
|
remove_lockfiles()
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user