Mercurial > noffle
annotate src/lock.c @ 306:52ce87d25641 noffle
[svn] added logging when fetching news started/finished
author | godisch |
---|---|
date | Mon, 17 Feb 2003 09:18:12 +0000 |
parents | 3477050e8d10 |
children |
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 |
271
3477050e8d10
[svn] * src/client.c,src/fetch.c,src/lock.c.src/protocol.c,src/util.h,src/util.c:
bears
parents:
197
diff
changeset
|
4 $Id: lock.c 403 2002-11-10 11:32:17Z 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 <errno.h> |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
13 #include <ctype.h> |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
14 #include <sys/types.h> |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
15 #include <sys/stat.h> |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
16 #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
|
17 #include <signal.h> |
54
125d79c9e586
[svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents:
43
diff
changeset
|
18 |
125d79c9e586
[svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents:
43
diff
changeset
|
19 #if TIME_WITH_SYS_TIME |
125d79c9e586
[svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents:
43
diff
changeset
|
20 #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
|
21 #include <time.h> |
54
125d79c9e586
[svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents:
43
diff
changeset
|
22 #else |
125d79c9e586
[svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents:
43
diff
changeset
|
23 #if HAVE_SYS_TIME_H |
125d79c9e586
[svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents:
43
diff
changeset
|
24 #include <sys/time.h> |
125d79c9e586
[svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents:
43
diff
changeset
|
25 #else |
125d79c9e586
[svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents:
43
diff
changeset
|
26 #include <time.h> |
125d79c9e586
[svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents:
43
diff
changeset
|
27 #endif |
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 |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
30 #include <unistd.h> |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
31 #include "configfile.h" |
167
7ba337dafb2c
[svn] * TODO,content.c,lock.c,server.c,server.h: Remove bug notice re:
bears
parents:
165
diff
changeset
|
32 #include "content.h" |
197
24d4cd032da5
[svn] * AUTHORS,INSTALL,NEWS,README,TODO,docs/NOTES,src/client.c,src/protocol.c,
bears
parents:
185
diff
changeset
|
33 #include "lock.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 |
271
3477050e8d10
[svn] * src/client.c,src/fetch.c,src/lock.c.src/protocol.c,src/util.h,src/util.c:
bears
parents:
197
diff
changeset
|
55 static SignalHandler oldHandler = NULL; |
165
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 ) ); |
185
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
183
diff
changeset
|
104 Log_dbg( LOG_DBG_NEWSBASE, "Waiting for lock %s ...", lock->name ); |
127 | 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 { |
271
3477050e8d10
[svn] * src/client.c,src/fetch.c,src/lock.c.src/protocol.c,src/util.h,src/util.c:
bears
parents:
197
diff
changeset
|
119 SignalHandler oldAlarmHandler; |
165
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; | |
185
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
183
diff
changeset
|
161 Log_dbg( LOG_DBG_NEWSBASE, "Lock successful" ); |
43
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; | |
185
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
183
diff
changeset
|
180 Log_dbg( LOG_DBG_NEWSBASE, "Releasing lock" ); |
43
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 |
183
c912e8288164
[svn] * src/client.c: Only bail out of fetching multiple articles if the
bears
parents:
167
diff
changeset
|
236 /* |
c912e8288164
[svn] * src/client.c: Only bail out of fetching multiple articles if the
bears
parents:
167
diff
changeset
|
237 * If we hold the lock right now, flag it to be released next close. |
c912e8288164
[svn] * src/client.c: Only bail out of fetching multiple articles if the
bears
parents:
167
diff
changeset
|
238 * Otherwise, if we are holding it lazily, release it. |
c912e8288164
[svn] * src/client.c: Only bail out of fetching multiple articles if the
bears
parents:
167
diff
changeset
|
239 */ |
165
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
240 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
|
241 globalLock.lazyClose = FALSE; |
183
c912e8288164
[svn] * src/client.c: Only bail out of fetching multiple articles if the
bears
parents:
167
diff
changeset
|
242 else if ( gotLock( &globalLock ) ) |
165
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
243 closeDatabases(); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
244 return; |
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 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
247 /* 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
|
248 Bool |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
249 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
|
250 { |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
251 Bool res; |
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 /* 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
|
254 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
|
255 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
|
256 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
257 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
|
258 return FALSE; |
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 ( ! globalLock.lazyClose ) |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
261 res = openDatabases(); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
262 else |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
263 res = TRUE; |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
264 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
265 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
|
266 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
267 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
|
268 return FALSE; |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
269 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
270 return res; |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
271 } |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
272 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
273 /* 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
|
274 void |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
275 Lock_closeDatabases( void ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
276 { |
165
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
277 blockSignal( TRUE ); |
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 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
|
280 closeDatabases(); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
281 else |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
282 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
|
283 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
284 blockSignal( FALSE ); |
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 |
183
c912e8288164
[svn] * src/client.c: Only bail out of fetching multiple articles if the
bears
parents:
167
diff
changeset
|
287 /* Sync all databases to disc. Maintain global lock status. */ |
165
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
288 void |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
289 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
|
290 { |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
291 Bool wasOpen; |
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 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
|
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( TRUE ); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
296 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
297 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
|
298 closeDatabases(); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
299 if ( wasOpen ) |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
300 openDatabases(); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
301 |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
302 blockSignal( FALSE ); |
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
303 } |
127 | 304 } |
305 | |
306 /* Check the global lock held. */ | |
307 Bool | |
308 Lock_gotLock( void ) | |
309 { | |
165
8ea6b5ddc5a5
[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents:
127
diff
changeset
|
310 return globalLock.lazyLockBusy; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
311 } |
127 | 312 |
313 /* Get fetch lock. */ | |
314 Bool | |
315 Lock_getFetchLock( enum LockRequestWait wait ) | |
316 { | |
317 return waitLock( &fetchLock, wait ); | |
318 } | |
319 | |
320 /* Release fetch lock. */ | |
321 void | |
322 Lock_releaseFetchLock( void ) | |
323 { | |
324 releaseLock( &fetchLock ); | |
325 } | |
326 | |
327 /* Check the fetch lock held. */ | |
328 Bool | |
329 Lock_fetchLock( void ) | |
330 { | |
331 return gotLock( &fetchLock ); | |
332 } | |
333 |