SQLite

Check-in [a4741cb54d]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add missing mutexes to unixShmClose().
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | wal
Files: files | file ages | folders
SHA1: a4741cb54dd5e753d48fd05ac9dbe27ee4aa1ec0
User & Date: dan 2010-04-30 10:06:10.000
Context
2010-04-30
10:24
Fix an assert() in sqlite3WalRead(). (check-in: 2e7a0050e1 user: dan tags: wal)
10:06
Add missing mutexes to unixShmClose(). (check-in: a4741cb54d user: dan tags: wal)
09:52
Fix a couple of assert() statements in os_unix.c and wal.c. Combine sqlite3WalIsDirty() with sqlite3WalUndo(). (check-in: a8f958be80 user: dan tags: wal)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/os_unix.c.
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072



5073
5074
5075


5076
5077
5078
5079
5080
5081
5082
/*
** Close a connectioon to shared-memory.
*/
static int unixShmClose(sqlite3_shm *pSharedMem){
  unixShm *p;            /* The connection to be closed */
  unixShmFile *pFile;    /* The underlying shared-memory file */
  unixShm **pp;          /* For looping over sibling connections */
  int nRef;              /* Number of connections to pFile */

  if( pSharedMem==0 ) return SQLITE_OK;
  p = (struct unixShm*)pSharedMem;
  pFile = p->pFile;

  /* Verify that the connection being closed holds no locks */
  assert( p->exclMask==0 );
  assert( p->sharedMask==0 );


  /* Remove connection p from the set of connections associated with pFile */
  sqlite3_mutex_enter(pFile->mutex);
  for(pp=&pFile->pFirst; (*pp)!=p; pp = &(*pp)->pNext){}
  *pp = p->pNext;
  pFile->nRef--;
  nRef = pFile->nRef;

  /* Free the connection p */
  sqlite3_free(p);
  sqlite3_mutex_leave(pFile->mutex);

  /* If pFile->nRef has reached 0, then close the underlying
  ** shared-memory file, too */



  if( nRef==0 ){
    unixShmPurge();
  }


  return SQLITE_OK;
}

/*
** Query and/or changes the size of a shared-memory segment.
** The reqSize parameter is the new size of the segment, or -1 to
** do just a query.  The size of the segment after resizing is







<









<




<
<







>
>
>
|


>
>







5042
5043
5044
5045
5046
5047
5048

5049
5050
5051
5052
5053
5054
5055
5056
5057

5058
5059
5060
5061


5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
/*
** Close a connectioon to shared-memory.
*/
static int unixShmClose(sqlite3_shm *pSharedMem){
  unixShm *p;            /* The connection to be closed */
  unixShmFile *pFile;    /* The underlying shared-memory file */
  unixShm **pp;          /* For looping over sibling connections */


  if( pSharedMem==0 ) return SQLITE_OK;
  p = (struct unixShm*)pSharedMem;
  pFile = p->pFile;

  /* Verify that the connection being closed holds no locks */
  assert( p->exclMask==0 );
  assert( p->sharedMask==0 );


  /* Remove connection p from the set of connections associated with pFile */
  sqlite3_mutex_enter(pFile->mutex);
  for(pp=&pFile->pFirst; (*pp)!=p; pp = &(*pp)->pNext){}
  *pp = p->pNext;



  /* Free the connection p */
  sqlite3_free(p);
  sqlite3_mutex_leave(pFile->mutex);

  /* If pFile->nRef has reached 0, then close the underlying
  ** shared-memory file, too */
  unixEnterMutex();
  assert( pFile->nRef>0 );
  pFile->nRef--;
  if( pFile->nRef==0 ){
    unixShmPurge();
  }
  unixLeaveMutex();

  return SQLITE_OK;
}

/*
** Query and/or changes the size of a shared-memory segment.
** The reqSize parameter is the new size of the segment, or -1 to
** do just a query.  The size of the segment after resizing is