annotate src/lock.c @ 129:6b2b93288caa noffle

[svn] Fix potential lock bug
author bears
date Wed, 09 Aug 2000 22:20:12 +0100
parents 3c71e28c8eef
children 8ea6b5ddc5a5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
4 $Id: lock.c 183 2000-07-25 12:14:54Z 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>
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"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
32 #include "log.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
33 #include "database.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
34 #include "group.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
35 #include "request.h"
54
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 43
diff changeset
36 #include "portable.h"
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
37
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
38 struct Lock
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
39 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
40 const char *name;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
41 int lockFd;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
42 Str lockFile;
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
43 };
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
44
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
45 struct Lock globalLock = { "global", -1, "" };
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
46 struct Lock fetchLock = { "fetch", -1, "" };
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
47
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
48 /* 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
49 static Bool
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
50 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
51 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
52 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
53 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
54
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
55 static Bool
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
56 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
57 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
58 int fd;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
59 struct flock l;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
60
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
61 ASSERT( ! gotLock( lock ) );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
62 Log_dbg( "Waiting for lock %s ...", lock->name );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
63 if ( lock->lockFile[ 0 ] == '\0' )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
64 snprintf( lock->lockFile, MAXCHAR, "%s/lock/%s",
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
65 Cfg_spoolDir(), lock->name );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
66 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
67 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
68 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
69 return FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
70 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
71 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
72 l.l_start = 0;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
73 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
74 l.l_len = 0;
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
75 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
76 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
77 if ( fcntl( fd, F_SETLKW, &l ) < 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
78 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
79 Log_err( "Cannot lock %s: %s", lock->lockFile, strerror( errno ) );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
80 close( lock->lockFd );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
81 return FALSE;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
82 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
83 }
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
84 else
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
85 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
86 if ( fcntl( fd, F_SETLK, &l ) < 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
87 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
88 close( lock->lockFd );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
89 return FALSE;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
90 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
91 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
92
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
93 lock->lockFd = fd;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
94 Log_dbg( "Lock successful" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
95 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
96 }
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 static void
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
99 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
100 {
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
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
103 ASSERT( gotLock( lock ) );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
104 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
105 l.l_start = 0;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
106 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
107 l.l_len = 0;
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
108 if ( fcntl( lock->lockFd, F_SETLK, &l ) < 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
109 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
110 strerror( errno ) );
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
111 close( lock->lockFd );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
112 lock->lockFd = -1;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
113 Log_dbg( "Releasing lock" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
114 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
115
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
116
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
117 /* Open all databases and set global lock. */
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
118 Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
119 Lock_openDatabases( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
120 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
121 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
122 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
123 Log_err( "Could not get write lock" );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
124 return FALSE;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
125 }
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
126 if ( ! Db_open() )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
127 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
128 Log_err( "Could not open database" );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
129 releaseLock( &globalLock );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
130 return FALSE;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
131 }
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
132 if ( ! Grp_open() )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
133 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
134 Log_err( "Could not open groupinfo" );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
135 Db_close();
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
136 releaseLock( &globalLock );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
137 return FALSE;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
138 }
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
139 if ( ! Req_open() )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
140 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
141 Log_err( "Could not initialize request database" );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
142 Grp_close();
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
143 Db_close();
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
144 releaseLock( &globalLock );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
145 return FALSE;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
146 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
147
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
148 return TRUE;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
149 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
150
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
151
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
152 /* 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
153 void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
154 Lock_closeDatabases( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
155 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
156 Grp_close();
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
157 Db_close();
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
158 Req_close();
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
159 releaseLock( &globalLock );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
160 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
161
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
162 /* Check the global lock held. */
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
163 Bool
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
164 Lock_gotLock( void )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
165 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
166 return gotLock( &globalLock );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
167 }
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
168
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
169 /* Get fetch lock. */
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
170 Bool
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
171 Lock_getFetchLock( enum LockRequestWait wait )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
172 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
173 return waitLock( &fetchLock, wait );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
174 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
175
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
176 /* Release fetch lock. */
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
177 void
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
178 Lock_releaseFetchLock( void )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
179 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
180 releaseLock( &fetchLock );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
181 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
182
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
183 /* Check the fetch lock held. */
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
184 Bool
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
185 Lock_fetchLock( void )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
186 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
187 return gotLock( &fetchLock );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
188 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 54
diff changeset
189