comparison src/lock.c @ 185:fed1334d766b noffle

[svn] * src/client.c: Change variable only used on constant to 'const'. * src/filter.c: Add a couple of 'return's after ASSERT() to remove compiler warnings about functions needing returns. * NEWS,TODO,configure,configure.in,noffle.conf.example,docs/NOTES, docs/noffle.conf.5,src/client.c,src/configfile.c,src/content.c, src/control.c,src/database.c,src/fetch.c,src/fetchlist.c,src/filter.c, src/group.c,src/lock.c,src/log.c,src/log.h,src/noffle.c,src/outgoing.c, src/post.c,src/protocol.c,src/request.c,src/server.c,src/util.c: Debug logging is always compiled and selected via noffle.conf. All debug logs are classified as all, none, config, control, expire, fetch, filter, newsbase, noffle, post, protocol, requests and server.
author bears
date Sun, 05 Aug 2001 09:24:22 +0100
parents c912e8288164
children 24d4cd032da5
comparison
equal deleted inserted replaced
184:9854ea5f295f 185:fed1334d766b
1 /* 1 /*
2 lock.c 2 lock.c
3 3
4 $Id: lock.c 292 2001-05-15 12:07:53Z bears $ 4 $Id: lock.c 300 2001-08-05 08:24:22Z bears $
5 */ 5 */
6 6
7 #if HAVE_CONFIG_H 7 #if HAVE_CONFIG_H
8 #include <config.h> 8 #include <config.h>
9 #endif 9 #endif
99 { 99 {
100 int fd; 100 int fd;
101 struct flock l; 101 struct flock l;
102 102
103 ASSERT( ! gotLock( lock ) ); 103 ASSERT( ! gotLock( lock ) );
104 Log_dbg( "Waiting for lock %s ...", lock->name ); 104 Log_dbg( LOG_DBG_NEWSBASE, "Waiting for lock %s ...", lock->name );
105 if ( lock->lockFile[ 0 ] == '\0' ) 105 if ( lock->lockFile[ 0 ] == '\0' )
106 snprintf( lock->lockFile, MAXCHAR, "%s/lock/%s", 106 snprintf( lock->lockFile, MAXCHAR, "%s/lock/%s",
107 Cfg_spoolDir(), lock->name ); 107 Cfg_spoolDir(), lock->name );
108 if ( ( fd = open( lock->lockFile, O_WRONLY | O_CREAT, 0644 ) ) < 0 ) 108 if ( ( fd = open( lock->lockFile, O_WRONLY | O_CREAT, 0644 ) ) < 0 )
109 { 109 {
156 return FALSE; 156 return FALSE;
157 } 157 }
158 } 158 }
159 159
160 lock->lockFd = fd; 160 lock->lockFd = fd;
161 Log_dbg( "Lock successful" ); 161 Log_dbg( LOG_DBG_NEWSBASE, "Lock successful" );
162 return TRUE; 162 return TRUE;
163 } 163 }
164 164
165 static void 165 static void
166 releaseLock( struct Lock *lock ) 166 releaseLock( struct Lock *lock )
175 if ( fcntl( lock->lockFd, F_SETLK, &l ) < 0 ) 175 if ( fcntl( lock->lockFd, F_SETLK, &l ) < 0 )
176 Log_err( "Cannot release %s: %s", lock->lockFile, 176 Log_err( "Cannot release %s: %s", lock->lockFile,
177 strerror( errno ) ); 177 strerror( errno ) );
178 close( lock->lockFd ); 178 close( lock->lockFd );
179 lock->lockFd = -1; 179 lock->lockFd = -1;
180 Log_dbg( "Releasing lock" ); 180 Log_dbg( LOG_DBG_NEWSBASE, "Releasing lock" );
181 } 181 }
182 182
183 static Bool 183 static Bool
184 openDatabases( void ) 184 openDatabases( void )
185 { 185 {