Mercurial > noffle
annotate src/lock.c @ 167:7ba337dafb2c noffle
[svn] * TODO,content.c,lock.c,server.c,server.h: Remove bug notice re:
need to do a Cont_write on Lock_closeDatabases in case of unwritten
content changes when releasing the lock. Update content to keep dirty
flag and avoid unnecessary writes, and lock to signal server to re-read
its group content info after the lock is released. Do NOT write content
info on Lock_close if dirty, as the placeholder article in unsubscribed
groups is currently done by adding it to the content when joining the
group and deliberately not saving it unless another content modification
takes place and thus causes the content to be saved.
author | bears |
---|---|
date | Sun, 25 Feb 2001 23:29:50 +0000 |
parents | 8ea6b5ddc5a5 |
children | c912e8288164 |
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 |
167
7ba337dafb2c
[svn] * TODO,content.c,lock.c,server.c,server.h: Remove bug notice re:
bears
parents:
165
diff
changeset
|
4 $Id: lock.c 260 2001-02-25 23:29:50Z 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" |
167
7ba337dafb2c
[svn] * TODO,content.c,lock.c,server.c,server.h: Remove bug notice re:
bears
parents:
165
diff
changeset
|
33 #include "content.h" |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
34 #include "log.h" |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
35 #include "database.h" |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
36 #include "group.h" |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
37 #include "request.h" |
54
125d79c9e586
[svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents:
43
diff
changeset
|
38 #include "portable.h" |
167
7ba337dafb2c
[svn] * TODO,content.c,lock.c,server.c,server.h: Remove bug notice re:
bears
parents:
165
diff
changeset
|
39 #include "server.h" |
165
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
40 #include "util.h" |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
41 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
42 struct Lock |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
43 { |
127 | 44 const char *name; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
45 int lockFd; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
46 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
|
47 Bool doLazyLocking; |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
48 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
|
49 volatile Bool lazyLockBusy; |
127 | 50 }; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
51 |
167
7ba337dafb2c
[svn] * TODO,content.c,lock.c,server.c,server.h: Remove bug notice re:
bears
parents:
165
diff
changeset
|
52 static struct Lock globalLock = { "global", -1, "", TRUE, FALSE, FALSE }; |
7ba337dafb2c
[svn] * TODO,content.c,lock.c,server.c,server.h: Remove bug notice re:
bears
parents:
165
diff
changeset
|
53 static struct Lock fetchLock = { "fetch", -1, "", FALSE, FALSE, FALSE }; |
165
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 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
|
56 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
57 /* 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
|
58 static Bool |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
59 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
|
60 { |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
61 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
|
62 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
63 sigemptyset(&sigs); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
64 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
|
65 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
66 for(;;) |
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 ( 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
|
69 { |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
70 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
|
71 { |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
72 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
|
73 return FALSE; |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
74 } |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
75 } |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
76 else |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
77 return TRUE; |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
78 } |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
79 /* NOTREACHED */ |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
80 } |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
81 |
127 | 82 /* 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
|
83 static Bool |
127 | 84 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
|
85 { |
127 | 86 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
|
87 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
88 |
165
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
89 static void |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
90 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
|
91 { |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
92 UNUSED( sig ); |
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 return; |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
95 } |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
96 |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
97 static Bool |
127 | 98 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
|
99 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
100 int fd; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
101 struct flock l; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
102 |
127 | 103 ASSERT( ! gotLock( lock ) ); |
104 Log_dbg( "Waiting for lock %s ...", lock->name ); | |
105 if ( lock->lockFile[ 0 ] == '\0' ) | |
106 snprintf( lock->lockFile, MAXCHAR, "%s/lock/%s", | |
107 Cfg_spoolDir(), lock->name ); | |
108 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
|
109 { |
127 | 110 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
|
111 return FALSE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
112 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
113 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
|
114 l.l_start = 0; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
115 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
|
116 l.l_len = 0; |
127 | 117 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
|
118 { |
165
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
119 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
|
120 unsigned oldAlarm; |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
121 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
122 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
|
123 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
|
124 for(;;) |
127 | 125 { |
165
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
126 alarm( 1 ); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
127 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
|
128 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
|
129 { |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
130 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
|
131 alarm( oldAlarm ); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
132 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
|
133 strerror( errno ) ); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
134 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
|
135 return FALSE; |
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 else |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
138 { |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
139 /* 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
|
140 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
|
141 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
|
142 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
|
143 strerror( errno ) ); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
144 } |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
145 else |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
146 break; |
127 | 147 } |
165
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
148 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
|
149 alarm( oldAlarm ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
150 } |
127 | 151 else |
152 { | |
153 if ( fcntl( fd, F_SETLK, &l ) < 0 ) | |
154 { | |
155 close( lock->lockFd ); | |
156 return FALSE; | |
157 } | |
158 } | |
159 | |
160 lock->lockFd = fd; | |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
161 Log_dbg( "Lock successful" ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
162 return TRUE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
163 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
164 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
165 static void |
127 | 166 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
|
167 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
168 struct flock l; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
169 |
127 | 170 ASSERT( gotLock( lock ) ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
171 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
|
172 l.l_start = 0; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
173 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
|
174 l.l_len = 0; |
127 | 175 if ( fcntl( lock->lockFd, F_SETLK, &l ) < 0 ) |
176 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
|
177 strerror( errno ) ); |
127 | 178 close( lock->lockFd ); |
179 lock->lockFd = -1; | |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
180 Log_dbg( "Releasing lock" ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
181 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
182 |
165
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
183 static Bool |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
184 openDatabases( void ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
185 { |
165
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
186 globalLock.lazyClose = FALSE; |
127 | 187 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
|
188 { |
127 | 189 Log_err( "Could not get write lock" ); |
190 return FALSE; | |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
191 } |
127 | 192 if ( ! Db_open() ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
193 { |
127 | 194 Log_err( "Could not open database" ); |
195 releaseLock( &globalLock ); | |
196 return FALSE; | |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
197 } |
127 | 198 if ( ! Grp_open() ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
199 { |
127 | 200 Log_err( "Could not open groupinfo" ); |
201 Db_close(); | |
202 releaseLock( &globalLock ); | |
203 return FALSE; | |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
204 } |
127 | 205 if ( ! Req_open() ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
206 { |
127 | 207 Log_err( "Could not initialize request database" ); |
208 Grp_close(); | |
209 Db_close(); | |
210 releaseLock( &globalLock ); | |
211 return FALSE; | |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
212 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
213 |
165
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
214 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
|
215 globalLock.lazyLockBusy = TRUE; |
127 | 216 return TRUE; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
217 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
218 |
165
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
219 static void |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
220 closeDatabases( void ) |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
221 { |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
222 Grp_close(); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
223 Db_close(); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
224 Req_close(); |
167
7ba337dafb2c
[svn] * TODO,content.c,lock.c,server.c,server.h: Remove bug notice re:
bears
parents:
165
diff
changeset
|
225 Server_flushCache(); |
165
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
226 releaseLock( &globalLock ); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
227 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
|
228 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
|
229 } |
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 static void |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
232 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
|
233 { |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
234 UNUSED( sig ); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
235 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
236 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
|
237 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
|
238 else |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
239 closeDatabases(); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
240 return; |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
241 } |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
242 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
243 /* 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
|
244 Bool |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
245 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
|
246 { |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
247 Bool res; |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
248 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
249 /* 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
|
250 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
|
251 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
|
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 ( ! blockSignal( TRUE ) ) |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
254 return FALSE; |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
255 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
256 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
|
257 res = openDatabases(); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
258 else |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
259 res = TRUE; |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
260 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
261 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
|
262 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
263 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
|
264 return FALSE; |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
265 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
266 return res; |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
267 } |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
268 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
269 /* 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
|
270 void |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
271 Lock_closeDatabases( void ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
272 { |
165
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
273 blockSignal( TRUE ); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
274 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
275 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
|
276 closeDatabases(); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
277 else |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
278 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
|
279 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
280 blockSignal( FALSE ); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
281 } |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
282 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
283 /* 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
|
284 void |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
285 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
|
286 { |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
287 Bool wasOpen; |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
288 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
289 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
|
290 { |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
291 blockSignal( TRUE ); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
292 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
293 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
|
294 closeDatabases(); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
295 if ( wasOpen ) |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
296 openDatabases(); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
297 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
298 blockSignal( FALSE ); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
299 } |
127 | 300 } |
301 | |
302 /* Check the global lock held. */ | |
303 Bool | |
304 Lock_gotLock( void ) | |
305 { | |
165
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
306 return globalLock.lazyLockBusy; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
307 } |
127 | 308 |
309 /* Get fetch lock. */ | |
310 Bool | |
311 Lock_getFetchLock( enum LockRequestWait wait ) | |
312 { | |
313 return waitLock( &fetchLock, wait ); | |
314 } | |
315 | |
316 /* Release fetch lock. */ | |
317 void | |
318 Lock_releaseFetchLock( void ) | |
319 { | |
320 releaseLock( &fetchLock ); | |
321 } | |
322 | |
323 /* Check the fetch lock held. */ | |
324 Bool | |
325 Lock_fetchLock( void ) | |
326 { | |
327 return gotLock( &fetchLock ); | |
328 } | |
329 |