From: shaneh Date: Wed, 12 May 2010 17:14:59 +0000 (+0000) Subject: Updates to WAL support in os_win.c: pulled in latest changes from src/os_unix.c;... X-Git-Tag: version-3.7.2~358^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=50f6455f4181ca882081582aa2a7dd820583e382;p=thirdparty%2Fsqlite.git Updates to WAL support in os_win.c: pulled in latest changes from src/os_unix.c; updated tracing; misc. improvements. FossilOrigin-Name: 76504726a1ef7f6a0445ec800776462138b22d72 --- diff --git a/manifest b/manifest index 4e9bc69639..2bdebe33df 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Initial\sport\sof\sWAL\sVFS\ssupport\sfrom\sos_unix.c\sto\sos_win.c. -D 2010-05-11T02:49:40 +C Updates\sto\sWAL\ssupport\sin\sos_win.c:\spulled\sin\slatest\schanges\sfrom\ssrc/os_unix.c;\supdated\stracing;\smisc.\simprovements. +D 2010-05-12T17:14:59 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in a5cad1f8f3e021356bfcc6c77dc16f6f1952bbc3 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -153,7 +153,7 @@ F src/os.h b389844e5469a2918e8a45fe6ae52b4c28dfb2b2 F src/os_common.h 0d6ee583b6ee3185eb9d951f890c6dd03021a08d F src/os_os2.c 8ad77a418630d7dee91d1bb04f79c2096301d3a0 F src/os_unix.c 34fe71c67fce72360411d60fe069c7f0dc612dd0 -F src/os_win.c 0bd6984370374b0bbd374e9109bac13c6abdaae8 +F src/os_win.c 858e38344cab4b8c82be3263dd997c8f0f07ee0c F src/pager.c a47af9c2c9ca425bd68642d61764266331a3323f F src/pager.h 934b598583a9d936bb13c37d62a2fe68ac48781c F src/parse.y ace5c7a125d9f2a410e431ee3209034105045f7e @@ -813,11 +813,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 6a5630806c87b0f4e5632c37c357f98effd9608a -R c58b69cb1a4b14b3d6dec9bb095f2635 -T *bgcolor * #c0f0ff -T *branch * wal-win32 -T *sym-wal-win32 * -T -sym-trunk * +P 111ad59f21d53d1ec63c084ca5f98f2aaf7cd070 +R dbc78c75ab3394a3992dedd59d6e1ec0 U shaneh -Z f2e493f04213be36370a416f3e148539 +Z 1406477810564323a0dea454027b6d3a diff --git a/manifest.uuid b/manifest.uuid index 96f8cc0f10..0bf12bb074 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -111ad59f21d53d1ec63c084ca5f98f2aaf7cd070 \ No newline at end of file +76504726a1ef7f6a0445ec800776462138b22d72 \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index b2e9c82135..7783115288 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -924,8 +924,8 @@ static int winLock(sqlite3_file *id, int locktype){ DWORD error = NO_ERROR; assert( id!=0 ); - OSTRACE5("LOCK %d %d was %d(%d)\n", - pFile->h, locktype, pFile->locktype, pFile->sharedLockByte); + OSTRACE(("LOCK %d %d was %d(%d)\n", + pFile->h, locktype, pFile->locktype, pFile->sharedLockByte)); /* If there is already a lock of this type or more restrictive on the ** OsFile, do nothing. Don't use the end_lock: exit path, as @@ -1413,7 +1413,9 @@ static int winOpen( ); #endif } - OSTRACE4("OPEN %d %s 0x%lx\n", h, zName, dwDesiredAccess); + OSTRACE(("OPEN %d %s 0x%lx %s\n", + h, zName, dwDesiredAccess, + h==INVALID_HANDLE_VALUE ? "failed" : "ok")); if( h==INVALID_HANDLE_VALUE ){ free(zConverted); if( flags & SQLITE_OPEN_READWRITE ){ @@ -2087,10 +2089,15 @@ static int winShmSystemLock( /* Initialize the locking parameters */ if( lockMask==WIN_SHM_C && lockType!=_SHM_UNLCK ){ dwFlags = 0; - OSTRACE(("SHM-LOCK requesting blocking lock %s\n", winShmLockString(lockMask))); + OSTRACE(("SHM-LOCK %d requesting blocking lock %s\n", + pFile->hFile.h, + winShmLockString(lockMask))); }else{ dwFlags = LOCKFILE_FAIL_IMMEDIATELY; - OSTRACE(("SHM-LOCK requesting %s %s\n", lockType!=_SHM_UNLCK ? "unlock" : "lock", winShmLockString(lockMask))); + OSTRACE(("SHM-LOCK %d requesting %s %s\n", + pFile->hFile.h, + lockType!=_SHM_UNLCK ? "lock" : "unlock", + winShmLockString(lockMask))); } if( lockType == _SHM_WRLCK ) dwFlags |= LOCKFILE_EXCLUSIVE_LOCK; @@ -2099,7 +2106,6 @@ static int winShmSystemLock( assert( mask!=0 ); memset(&ovlp, 0, sizeof(OVERLAPPED)); ovlp.Offset = i+WIN_SHM_BASE; - ovlp.OffsetHigh = 0; nBytes = 1; /* Extend the locking range for each additional bit that is set */ @@ -2118,31 +2124,23 @@ static int winShmSystemLock( rc = UnlockFileEx(pFile->hFile.h, 0, 1, 0, &ovlp); if( !rc ) break; } - if( !rc ){ - OSTRACE(("SHM-LOCK UnlockFileEx ERROR %d - 0x%08lx\n", rc, GetLastError())); - /* continue to release individual byte locks (if any) */ - for(; ihFile.h, 0, 1, 0, &ovlp); - } - } }else{ - /* release old individual byte locks (if any). */ + /* release old individual byte locks (if any) + ** and set new individual byte locks */ for(i=0; ihFile.h, 0, 1, 0, &ovlp); - } - ovlp.Offset-=nBytes; - /* set new individual byte locks */ - for(i=0; i<(int)nBytes; i++, ovlp.Offset++){ rc = LockFileEx(pFile->hFile.h, dwFlags, 0, 1, 0, &ovlp); if( !rc ) break; } - if( !rc ){ - OSTRACE(("SHM-LOCK LockFileEx ERROR %d - 0x%08lx\n", rc, GetLastError())); - /* release individual byte locks (if any) */ - ovlp.Offset-=i; - for(i=0; ihFile.h, 0, 1, 0, &ovlp); - } + } + if( !rc ){ + OSTRACE(("SHM-LOCK %d %s ERROR 0x%08lx\n", + pFile->hFile.h, + lockType==_SHM_UNLCK ? "UnlockFileEx" : "LockFileEx", GetLastError())); + /* release individual byte locks (if any) */ + ovlp.Offset-=i; + for(i=0; ihFile.h, 0, 1, 0, &ovlp); } } rc = (rc!=0) ? SQLITE_OK : SQLITE_BUSY; @@ -2202,7 +2200,8 @@ static int winShmUnlock( /* don't attempt to unlock anything we don't have locks for */ if( (unlockMask & (p->exclMask|p->sharedMask)) != unlockMask ){ - OSTRACE(("SHM-UNLOCKING more than we have locked - requested %s - have %s\n", + OSTRACE(("SHM-LOCK %d unlocking more than we have locked - requested %s - have %s\n", + pFile->hFile.h, winShmLockString(unlockMask), winShmLockString(p->exclMask|p->sharedMask))); unlockMask &= (p->exclMask|p->sharedMask); @@ -2358,11 +2357,15 @@ static int winShmOpen( const char *zName, /* Name of the corresponding database file */ sqlite3_shm **pShm /* Write the winShm object created here */ ){ - struct winShm *p = 0; /* The connection to be opened */ + struct winShm *p; /* The connection to be opened */ struct winShmFile *pFile = 0; /* The underlying mmapped file */ int rc; /* Result code */ struct winShmFile *pNew; /* Newly allocated pFile */ int nName; /* Size of zName in bytes */ + char zFullpath[MAX_PATH+1]; /* Temp buffer for full file name */ + + rc = winFullPathname(pVfs, zName, MAX_PATH, zFullpath); + if( rc ) return rc; /* Allocate space for the new sqlite3_shm object. Also speculatively ** allocate space for a new winShmFile and filename. @@ -2370,7 +2373,7 @@ static int winShmOpen( p = sqlite3_malloc( sizeof(*p) ); if( p==0 ) return SQLITE_NOMEM; memset(p, 0, sizeof(*p)); - nName = strlen(zName); + nName = sqlite3Strlen30(zFullpath); pNew = sqlite3_malloc( sizeof(*pFile) + nName + 15 ); if( pNew==0 ){ sqlite3_free(p); @@ -2378,7 +2381,7 @@ static int winShmOpen( } memset(pNew, 0, sizeof(*pNew)); pNew->zFilename = (char*)&pNew[1]; - sqlite3_snprintf(nName+11, pNew->zFilename, "%s-wal-index", zName); + sqlite3_snprintf(nName+12, pNew->zFilename, "%s-wal-index", zFullpath); /* Look to see if there is an existing winShmFile that can be used. ** If no matching winShmFile currently exists, create a new one. @@ -2386,9 +2389,9 @@ static int winShmOpen( winShmEnterMutex(); for(pFile = winShmFileList; pFile; pFile=pFile->pNext){ /* TBD need to come up with better match here. Perhaps - ** use winFullPathname() or FILE_ID_BOTH_DIR_INFO Structure. + ** use FILE_ID_BOTH_DIR_INFO Structure. */ - if( strcmp(pFile->zFilename, pNew->zFilename)==0 ) break; + if( sqlite3StrICmp(pFile->zFilename, pNew->zFilename)==0 ) break; } if( pFile ){ sqlite3_free(pNew); @@ -2411,7 +2414,6 @@ static int winShmOpen( rc = SQLITE_NOMEM; goto shm_open_err; } - rc = winOpen(pVfs, pFile->zFilename, /* Name of the file (UTF-8) */ (sqlite3_file *)&pFile->hFile, /* Write the SQLite file handle here */ @@ -2720,14 +2722,16 @@ static int winShmLock( if( desiredLock==p->lockState || (desiredLock==SQLITE_SHM_READ && p->lockState==SQLITE_SHM_READ_FULL) ){ - OSTRACE(("SHM-LOCK shmid-%d, pid-%d request %s and got %s\n", + OSTRACE(("SHM-LOCK %d shmid-%d, pid-%d request %s and got %s\n", + pFile->hFile.h, p->id, (int)GetCurrentProcessId(), azLkName[desiredLock], azLkName[p->lockState])); if( pGotLock ) *pGotLock = p->lockState; return SQLITE_OK; } - OSTRACE(("SHM-LOCK shmid-%d, pid-%d request %s->%s\n", - p->id, (int)GetCurrentProcessId(), azLkName[p->lockState], azLkName[desiredLock])); + OSTRACE(("SHM-LOCK %d shmid-%d, pid-%d request %s->%s\n", + pFile->hFile.h, + p->id, (int)GetCurrentProcessId(), azLkName[p->lockState], azLkName[desiredLock])); if( desiredLock==SQLITE_SHM_RECOVER && !p->hasMutexBuf ){ assert( sqlite3_mutex_notheld(pFile->mutex) ); @@ -2810,7 +2814,8 @@ static int winShmLock( } } sqlite3_mutex_leave(pFile->mutex); - OSTRACE(("SHM-LOCK shmid-%d, pid-%d got %s\n", + OSTRACE(("SHM-LOCK %d shmid-%d, pid-%d got %s\n", + pFile->hFile.h, p->id, (int)GetCurrentProcessId(), azLkName[p->lockState])); if( pGotLock ) *pGotLock = p->lockState; return rc;