Mercurial > noffle
annotate src/lock.c @ 165:8ea6b5ddc5a5 noffle
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
the lock and close the databases if (a) another process signals us
SIGUSR1 indicating it wants the lock, or (b) it is explicitly requested by
a call to new function Lock_syncDatabases(). When waiting for the lock,
SIGUSR1 the holding process every second. This is all an attempt to
minimise the number of times we need to close and open the database.
When (ha!) the database is replaced by something that can handle
multiple simultaneous writers (with appropriate locking) this won't
be necessary.
author | bears |
---|---|
date | Thu, 25 Jan 2001 13:38:31 +0000 |
parents | 3c71e28c8eef |
children | 7ba337dafb2c |
rev | line source |
---|---|
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1 /* |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
2 lock.c |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
3 |
165
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
4 $Id: lock.c 249 2001-01-25 13:38:31Z bears $ |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
5 */ |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
6 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
7 #if HAVE_CONFIG_H |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
8 #include <config.h> |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
9 #endif |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
10 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
11 #include <stdio.h> |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
12 #include "lock.h" |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
13 #include <errno.h> |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
14 #include <ctype.h> |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
15 #include <sys/types.h> |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
16 #include <sys/stat.h> |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
17 #include <fcntl.h> |
165
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
18 #include <signal.h> |
54
125d79c9e586
[svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents:
43
diff
changeset
|
19 |
125d79c9e586
[svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents:
43
diff
changeset
|
20 #if TIME_WITH_SYS_TIME |
125d79c9e586
[svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents:
43
diff
changeset
|
21 #include <sys/time.h> |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
22 #include <time.h> |
54
125d79c9e586
[svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents:
43
diff
changeset
|
23 #else |
125d79c9e586
[svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents:
43
diff
changeset
|
24 #if HAVE_SYS_TIME_H |
125d79c9e586
[svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents:
43
diff
changeset
|
25 #include <sys/time.h> |
125d79c9e586
[svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents:
43
diff
changeset
|
26 #else |
125d79c9e586
[svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents:
43
diff
changeset
|
27 #include <time.h> |
125d79c9e586
[svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents:
43
diff
changeset
|
28 #endif |
125d79c9e586
[svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents:
43
diff
changeset
|
29 #endif |
125d79c9e586
[svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents:
43
diff
changeset
|
30 |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
31 #include <unistd.h> |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
32 #include "configfile.h" |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
33 #include "log.h" |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
34 #include "database.h" |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
35 #include "group.h" |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
36 #include "request.h" |
54
125d79c9e586
[svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents:
43
diff
changeset
|
37 #include "portable.h" |
165
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
38 #include "util.h" |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
39 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
40 struct Lock |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
41 { |
127 | 42 const char *name; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
43 int lockFd; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
44 Str lockFile; |
165
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
45 Bool doLazyLocking; |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
46 volatile Bool lazyClose; |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
47 volatile Bool lazyLockBusy; |
127 | 48 }; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
49 |
165
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
50 static struct Lock globalLock = { "global", -1, "", TRUE }; |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
51 static struct Lock fetchLock = { "fetch", -1, "", FALSE }; |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
52 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
53 static sig_t oldHandler = NULL; |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
54 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
55 /* Block/unblock SIGUSR1. */ |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
56 static Bool |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
57 blockSignal( Bool block ) |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
58 { |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
59 sigset_t sigs; |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
60 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
61 sigemptyset(&sigs); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
62 sigaddset(&sigs, SIGUSR1); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
63 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
64 for(;;) |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
65 { |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
66 if ( sigprocmask( block ? SIG_BLOCK : SIG_UNBLOCK, &sigs, NULL ) != 0 ) |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
67 { |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
68 if ( errno != EINTR ) |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
69 { |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
70 Log_err( "Can't block/unblock signal" ); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
71 return FALSE; |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
72 } |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
73 } |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
74 else |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
75 return TRUE; |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
76 } |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
77 /* NOTREACHED */ |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
78 } |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
79 |
127 | 80 /* Check the global lock held. */ |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
81 static Bool |
127 | 82 gotLock( struct Lock *lock ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
83 { |
127 | 84 return ( lock->lockFd != -1 ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
85 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
86 |
165
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
87 static void |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
88 lockWaitAlarm( int sig ) |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
89 { |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
90 UNUSED( sig ); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
91 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
92 return; |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
93 } |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
94 |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
95 static Bool |
127 | 96 waitLock( struct Lock *lock, enum LockRequestWait wait ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
97 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
98 int fd; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
99 struct flock l; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
100 |
127 | 101 ASSERT( ! gotLock( lock ) ); |
102 Log_dbg( "Waiting for lock %s ...", lock->name ); | |
103 if ( lock->lockFile[ 0 ] == '\0' ) | |
104 snprintf( lock->lockFile, MAXCHAR, "%s/lock/%s", | |
105 Cfg_spoolDir(), lock->name ); | |
106 if ( ( fd = open( lock->lockFile, O_WRONLY | O_CREAT, 0644 ) ) < 0 ) | |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
107 { |
127 | 108 Log_err( "Cannot open %s (%s)", lock->lockFile, strerror( errno ) ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
109 return FALSE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
110 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
111 l.l_type = F_WRLCK; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
112 l.l_start = 0; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
113 l.l_whence = SEEK_SET; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
114 l.l_len = 0; |
127 | 115 if ( wait == LOCK_WAIT ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
116 { |
165
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
117 sig_t oldAlarmHandler; |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
118 unsigned oldAlarm; |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
119 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
120 oldAlarmHandler = Utl_installSignalHandler( SIGALRM, lockWaitAlarm ); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
121 oldAlarm = alarm( 1 ); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
122 for(;;) |
127 | 123 { |
165
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
124 alarm( 1 ); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
125 if ( fcntl( fd, F_SETLKW, &l ) < 0 ) |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
126 if ( errno != EINTR ) |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
127 { |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
128 Utl_installSignalHandler( SIGALRM, oldAlarmHandler ); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
129 alarm( oldAlarm ); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
130 Log_err( "Cannot lock %s: %s", lock->lockFile, |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
131 strerror( errno ) ); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
132 close( lock->lockFd ); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
133 return FALSE; |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
134 } |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
135 else |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
136 { |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
137 /* Send SIGUSR1 to the process holding the lock. */ |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
138 if ( fcntl( fd, F_GETLK, &l) == 0 && l.l_type != F_UNLCK ) |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
139 if ( kill( l.l_pid, SIGUSR1 ) < 0 ) |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
140 Log_err( "Can't signal process %d: %s", l.l_pid, |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
141 strerror( errno ) ); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
142 } |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
143 else |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
144 break; |
127 | 145 } |
165
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
146 Utl_installSignalHandler( SIGALRM, oldAlarmHandler ); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
147 alarm( oldAlarm ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
148 } |
127 | 149 else |
150 { | |
151 if ( fcntl( fd, F_SETLK, &l ) < 0 ) | |
152 { | |
153 close( lock->lockFd ); | |
154 return FALSE; | |
155 } | |
156 } | |
157 | |
158 lock->lockFd = fd; | |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
159 Log_dbg( "Lock successful" ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
160 return TRUE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
161 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
162 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
163 static void |
127 | 164 releaseLock( struct Lock *lock ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
165 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
166 struct flock l; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
167 |
127 | 168 ASSERT( gotLock( lock ) ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
169 l.l_type = F_UNLCK; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
170 l.l_start = 0; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
171 l.l_whence = SEEK_SET; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
172 l.l_len = 0; |
127 | 173 if ( fcntl( lock->lockFd, F_SETLK, &l ) < 0 ) |
174 Log_err( "Cannot release %s: %s", lock->lockFile, | |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
175 strerror( errno ) ); |
127 | 176 close( lock->lockFd ); |
177 lock->lockFd = -1; | |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
178 Log_dbg( "Releasing lock" ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
179 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
180 |
165
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
181 static Bool |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
182 openDatabases( void ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
183 { |
165
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
184 globalLock.lazyClose = FALSE; |
127 | 185 if ( ! waitLock( &globalLock, LOCK_WAIT ) ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
186 { |
127 | 187 Log_err( "Could not get write lock" ); |
188 return FALSE; | |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
189 } |
127 | 190 if ( ! Db_open() ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
191 { |
127 | 192 Log_err( "Could not open database" ); |
193 releaseLock( &globalLock ); | |
194 return FALSE; | |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
195 } |
127 | 196 if ( ! Grp_open() ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
197 { |
127 | 198 Log_err( "Could not open groupinfo" ); |
199 Db_close(); | |
200 releaseLock( &globalLock ); | |
201 return FALSE; | |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
202 } |
127 | 203 if ( ! Req_open() ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
204 { |
127 | 205 Log_err( "Could not initialize request database" ); |
206 Grp_close(); | |
207 Db_close(); | |
208 releaseLock( &globalLock ); | |
209 return FALSE; | |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
210 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
211 |
165
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
212 globalLock.lazyClose = globalLock.doLazyLocking; |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
213 globalLock.lazyLockBusy = TRUE; |
127 | 214 return TRUE; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
215 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
216 |
165
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
217 static void |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
218 closeDatabases( void ) |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
219 { |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
220 Grp_close(); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
221 Db_close(); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
222 Req_close(); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
223 releaseLock( &globalLock ); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
224 globalLock.lazyLockBusy = FALSE; |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
225 globalLock.lazyClose = FALSE; |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
226 } |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
227 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
228 static void |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
229 lockSignal( int sig ) |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
230 { |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
231 UNUSED( sig ); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
232 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
233 if ( globalLock.lazyLockBusy ) |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
234 globalLock.lazyClose = FALSE; |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
235 else |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
236 closeDatabases(); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
237 return; |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
238 } |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
239 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
240 /* Open all databases and set global lock. */ |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
241 Bool |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
242 Lock_openDatabases( void ) |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
243 { |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
244 Bool res; |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
245 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
246 /* First time - need to initialise signal handler? */ |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
247 if ( oldHandler == NULL ) |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
248 oldHandler = Utl_installSignalHandler( SIGUSR1, lockSignal ); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
249 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
250 if ( ! blockSignal( TRUE ) ) |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
251 return FALSE; |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
252 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
253 if ( ! globalLock.lazyClose ) |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
254 res = openDatabases(); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
255 else |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
256 res = TRUE; |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
257 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
258 globalLock.lazyLockBusy = res; |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
259 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
260 if ( ! blockSignal( FALSE ) ) |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
261 return FALSE; |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
262 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
263 return res; |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
264 } |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
265 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
266 /* Close all databases and release global lock. */ |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
267 void |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
268 Lock_closeDatabases( void ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
269 { |
165
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
270 blockSignal( TRUE ); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
271 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
272 if ( ! globalLock.lazyClose ) |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
273 closeDatabases(); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
274 else |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
275 globalLock.lazyLockBusy = FALSE; |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
276 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
277 blockSignal( FALSE ); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
278 } |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
279 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
280 /* Sync al databases to disc. Maintain global lock status. */ |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
281 void |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
282 Lock_syncDatabases( void ) |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
283 { |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
284 Bool wasOpen; |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
285 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
286 if ( gotLock( &globalLock ) ) |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
287 { |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
288 blockSignal( TRUE ); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
289 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
290 wasOpen = globalLock.lazyLockBusy; |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
291 closeDatabases(); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
292 if ( wasOpen ) |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
293 openDatabases(); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
294 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
295 blockSignal( FALSE ); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
296 } |
127 | 297 } |
298 | |
299 /* Check the global lock held. */ | |
300 Bool | |
301 Lock_gotLock( void ) | |
302 { | |
165
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
303 return globalLock.lazyLockBusy; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
304 } |
127 | 305 |
306 /* Get fetch lock. */ | |
307 Bool | |
308 Lock_getFetchLock( enum LockRequestWait wait ) | |
309 { | |
310 return waitLock( &fetchLock, wait ); | |
311 } | |
312 | |
313 /* Release fetch lock. */ | |
314 void | |
315 Lock_releaseFetchLock( void ) | |
316 { | |
317 releaseLock( &fetchLock ); | |
318 } | |
319 | |
320 /* Check the fetch lock held. */ | |
321 Bool | |
322 Lock_fetchLock( void ) | |
323 { | |
324 return gotLock( &fetchLock ); | |
325 } | |
326 |