aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>1999-01-03 14:33:35 +0000
committerWerner Koch <[email protected]>1999-01-03 14:33:35 +0000
commite3e8d9b92f8b6fd0427fd5d99c66fda4596840cb (patch)
tree7788d39f49af5da5d6257ecbee119bc38529bdde /util
parentSee ChangeLog: Tue Dec 29 19:55:38 CET 1998 Werner Koch (diff)
downloadgnupg-e3e8d9b92f8b6fd0427fd5d99c66fda4596840cb.tar.gz
gnupg-e3e8d9b92f8b6fd0427fd5d99c66fda4596840cb.zip
See ChangeLog: Sun Jan 3 15:28:44 CET 1999 Werner Koch
Diffstat (limited to 'util')
-rw-r--r--util/ChangeLog7
-rw-r--r--util/dotlock.c34
2 files changed, 25 insertions, 16 deletions
diff --git a/util/ChangeLog b/util/ChangeLog
index f789bde53..217d92ee1 100644
--- a/util/ChangeLog
+++ b/util/ChangeLog
@@ -1,3 +1,10 @@
+Sun Jan 3 15:28:44 CET 1999 Werner Koch <[email protected]>
+
+ * dotlock.c (make_dotlock): print another informal message.
+
+ (make_dotlock): Removed the cpp checks.
+
+
Tue Dec 29 14:41:47 CET 1998 Werner Koch <[email protected]>
* secmem.c: Moved unistd.h out of the #ifdef
diff --git a/util/dotlock.c b/util/dotlock.c
index 69a38d696..620d8cdeb 100644
--- a/util/dotlock.c
+++ b/util/dotlock.c
@@ -59,21 +59,20 @@ make_dotlock( const char *file_to_lock, long timeout )
char *tname = NULL;
int have_tfile = 0;
struct utsname uts;
+ const char *nodename;
const char *dirpart;
int dirpartlen;
+ const char *maybe_dead="";
+ int backoff=0;
sprintf( pidstr, "%10d\n", getpid() );
/* fixme: add the hostname to the second line (FQDN or IP addr?) */
/* create a temporary file */
- #if defined(SYS_NMLN) && SYS_NMLN < 8
- #error Aiiih
- #elif !defined(SYS_NMLN) && MAXHOSTNAMELEN < 8
- /* (SunOS uses a structure of size MAXHOSTNAMELEN) */
- #error Aiiih
- #endif
if( uname( &uts ) )
- strcpy( uts.nodename, "unknown" );
+ nodename = "unknown";
+ else
+ nodename = uts.nodename;
if( !(dirpart = strrchr( file_to_lock, '/' )) ) {
dirpart = ".";
@@ -85,13 +84,13 @@ make_dotlock( const char *file_to_lock, long timeout )
}
#ifdef _THREAD_SAFE
- tname = m_alloc( dirpartlen + 6 + strlen(uts.nodename) + 11+ 20 );
+ tname = m_alloc( dirpartlen + 6 + strlen(nodename) + 11+ 20 );
sprintf( tname, "%.*s/.#lk.%s.%d.%p",
- dirpartlen, dirpart, uts.nodename, getpid(), &pid );
+ dirpartlen, dirpart, nodename, getpid(), &pid );
#else
- tname = m_alloc( dirpartlen + 6 + strlen(uts.nodename) + 11 );
+ tname = m_alloc( dirpartlen + 6 + strlen(nodename) + 11 );
sprintf( tname, "%.*s/.#lk.%s.%d",
- dirpartlen, dirpart, uts.nodename, getpid() );
+ dirpartlen, dirpart, nodename, getpid() );
#endif
do {
errno = 0;
@@ -135,21 +134,24 @@ make_dotlock( const char *file_to_lock, long timeout )
handle = lockname;
lockname = NULL;
}
- #if 0 /* we should not do this without checking the permissions */
- /* and the hostname */
else if( kill(pid, 0) && errno == ESRCH ) {
+ maybe_dead = " - probably dead";
+ #if 0 /* we should not do this without checking the permissions */
+ /* and the hostname */
log_info( "removing stale lockfile (created by %d)", pid );
remove( lockname );
goto retry;
+ #endif
}
- #endif
if( timeout == -1 ) {
struct timeval tv;
- log_info( "waiting for lock (hold by %d) ...\n", pid );
+ log_info( "waiting for lock (hold by %d%s) ...\n", pid, maybe_dead );
/* can't use sleep, cause signals may be blocked */
- tv.tv_sec = 1;
+ tv.tv_sec = 1 + backoff;
tv.tv_usec = 0;
select(0, NULL, NULL, NULL, &tv);
+ if( backoff < 10 )
+ backoff++ ;
goto retry;
}
/* fixme: implement timeouts */