Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Make os_unix compile with SQLITE_ENABLE_PROXY_LOCKING (CVS 5970) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
3efedac6aa4f544d40c2f782109d4e17 |
User & Date: | aswift 2008-12-03 21:26:20.000 |
Context
2008-12-03
| ||
22:32 | Reorganize the proxy-locking method in os_unix.c. Additional cleanup. (CVS 5971) (check-in: 31f6090e22 user: drh tags: trunk) | |
21:26 | Make os_unix compile with SQLITE_ENABLE_PROXY_LOCKING (CVS 5970) (check-in: 3efedac6aa user: aswift tags: trunk) | |
19:34 | Continue with the cleanup of os_unix.c. (CVS 5969) (check-in: 215d36ea89 user: drh tags: trunk) | |
Changes
Changes to src/os_unix.c.
︙ | ︙ | |||
39 40 41 42 43 44 45 | ** * sqlite3_file methods not associated with locking. ** * Definitions of sqlite3_io_methods objects for all locking ** methods plus "finder" functions for each locking method. ** * sqlite3_vfs method implementations. ** * Definitions of sqlite3_vfs objects for all locking methods ** plus implementations of sqlite3_os_init() and sqlite3_os_end(). ** | | | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | ** * sqlite3_file methods not associated with locking. ** * Definitions of sqlite3_io_methods objects for all locking ** methods plus "finder" functions for each locking method. ** * sqlite3_vfs method implementations. ** * Definitions of sqlite3_vfs objects for all locking methods ** plus implementations of sqlite3_os_init() and sqlite3_os_end(). ** ** $Id: os_unix.c,v 1.226 2008/12/03 21:26:20 aswift Exp $ */ #include "sqliteInt.h" #if SQLITE_OS_UNIX /* This file is used on unix only */ /* ** There are various methods for file locking used for concurrency ** control: |
︙ | ︙ | |||
2966 2967 2968 2969 2970 2971 2972 | return SQLITE_OK; } end_create_proxy: close(fd); /* silently leak fd if error, we're already in error */ sqlite3_free(pNew); return rc; } | | > > > > > > > > > > > > | 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 | return SQLITE_OK; } end_create_proxy: close(fd); /* silently leak fd if error, we're already in error */ sqlite3_free(pNew); return rc; } static const sqlite3_io_methods afpIoMethods; static int unixWrite( sqlite3_file *id, const void *pBuf, int amt, sqlite3_int64 offset ); static int unixRead( sqlite3_file *id, void *pBuf, int amt, sqlite3_int64 offset ); /* takes the conch by taking a shared lock and read the contents conch, if ** lockPath is non-NULL, the host ID and lock file path must match. A NULL ** lockPath means that the lockPath in the conch file will be used if the ** host IDs match, or a new lock path will be generated automatically ** and written to the conch file. */ static int proxyTakeConch(unixFile *pFile){ |
︙ | ︙ | |||
3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 | sqlite3_free(oldPath); pCtx->lockProxyPath = sqlite3DbStrDup(0, path); } return rc; } /* ** pFile is a file that has been opened by a prior xOpen call. dbPath ** is a string buffer at least MAXPATHLEN+1 characters in size. ** ** This routine find the filename associated with pFile and writes it ** int dbPath. */ static int proxyGetDbPathForUnixFile(unixFile *pFile, char *dbPath){ #if defined(__DARWIN__) if( pFile->pMethod == &afpIoMethods ){ /* afp style keeps a reference to the db path in the filePath field ** of the struct */ assert( strlen((char*)pFile->lockingContext)<=MAXPATHLEN ); | > | | | 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 | sqlite3_free(oldPath); pCtx->lockProxyPath = sqlite3DbStrDup(0, path); } return rc; } static const sqlite3_io_methods dotlockIoMethods; /* ** pFile is a file that has been opened by a prior xOpen call. dbPath ** is a string buffer at least MAXPATHLEN+1 characters in size. ** ** This routine find the filename associated with pFile and writes it ** int dbPath. */ static int proxyGetDbPathForUnixFile(unixFile *pFile, char *dbPath){ #if defined(__DARWIN__) if( pFile->pMethod == &afpIoMethods ){ /* afp style keeps a reference to the db path in the filePath field ** of the struct */ assert( strlen((char*)pFile->lockingContext)<=MAXPATHLEN ); strcpy(dbPath, ((afpLockingContext *)pFile->lockingContext)->dbPath); }else #endif if( pFile->pMethod == &dotlockIoMethods ){ /* dot lock style uses the locking context to store the dot lock ** file path */ int len = strlen((char *)pFile->lockingContext) - strlen(DOTLOCK_SUFFIX); memcpy(dbPath, (char *)pFile->lockingContext, len + 1); }else{ /* all other styles use the locking context to store the db file path */ assert( strlen((char*)pFile->lockingContext)<=MAXPATHLEN ); strcpy(dbPath, (char *)pFile->lockingContext); } return SQLITE_OK; } static const sqlite3_io_methods proxyIoMethods; /* ** Takes an already filled in unix file and alters it so all file locking ** will be performed on the local proxy lock file. The following fields ** are preserved in the locking context so that they can be restored and ** the unix structure properly cleaned up at close time: ** ->lockingContext ** ->pMethod |
︙ | ︙ | |||
4168 4169 4170 4171 4172 4173 4174 | if( pLockingStyle == &posixIoMethods ){ unixEnterMutex(); rc = findLockInfo(pNew, &pNew->pLock, &pNew->pOpen); unixLeaveMutex(); } #if SQLITE_ENABLE_LOCKING_STYLE && defined(__DARWIN__) | | | 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 | if( pLockingStyle == &posixIoMethods ){ unixEnterMutex(); rc = findLockInfo(pNew, &pNew->pLock, &pNew->pOpen); unixLeaveMutex(); } #if SQLITE_ENABLE_LOCKING_STYLE && defined(__DARWIN__) else if( pLockingStyle == &afpIoMethods ){ /* AFP locking uses the file path so it needs to be included in ** the afpLockingContext. */ afpLockingContext *pCtx; pNew->lockingContext = pCtx = sqlite3_malloc( sizeof(*pCtx) ); if( pCtx==0 ){ rc = SQLITE_NOMEM; |
︙ | ︙ |