SQLite

Check-in [ba8819a6f3]
Login

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

Overview
Comment:Fix a malloc() failure related problem in os_unix.c. (CVS 5328)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: ba8819a6f3dbc45d88346789de42971aacc0d246
User & Date: danielk1977 2008-06-30 10:16:05.000
Context
2008-06-30
15:09
Changes to loadext.test so that it works on osx as well as linux. (CVS 5329) (check-in: 189cd85413 user: danielk1977 tags: trunk)
10:16
Fix a malloc() failure related problem in os_unix.c. (CVS 5328) (check-in: ba8819a6f3 user: danielk1977 tags: trunk)
07:53
Add a couple of tests to see if the new compound select optimizations work when the compound select is hidden inside a view. (CVS 5327) (check-in: 1a711249c2 user: danielk1977 tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/os_unix.c.
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
******************************************************************************
**
** This file contains code that is specific to Unix systems.
**
** $Id: os_unix.c,v 1.191 2008/06/28 11:23:00 danielk1977 Exp $
*/
#include "sqliteInt.h"
#if SQLITE_OS_UNIX              /* This file is used on unix only */

/*
** If SQLITE_ENABLE_LOCKING_STYLE is defined, then several different 
** locking implementations are provided:







|







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
******************************************************************************
**
** This file contains code that is specific to Unix systems.
**
** $Id: os_unix.c,v 1.192 2008/06/30 10:16:05 danielk1977 Exp $
*/
#include "sqliteInt.h"
#if SQLITE_OS_UNIX              /* This file is used on unix only */

/*
** If SQLITE_ENABLE_LOCKING_STYLE is defined, then several different 
** locking implementations are provided:
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
** Close a file.
*/
static int unixClose(sqlite3_file *id){
  if( id ){
    unixFile *pFile = (unixFile *)id;
    unixUnlock(id, NO_LOCK);
    enterMutex();
    if( pFile->pOpen->nLock ){
      /* If there are outstanding locks, do not actually close the file just
      ** yet because that would clear those locks.  Instead, add the file
      ** descriptor to pOpen->aPending.  It will be automatically closed when
      ** the last lock is cleared.
      */
      int *aNew;
      struct openCnt *pOpen = pFile->pOpen;







|







1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
** Close a file.
*/
static int unixClose(sqlite3_file *id){
  if( id ){
    unixFile *pFile = (unixFile *)id;
    unixUnlock(id, NO_LOCK);
    enterMutex();
    if( pFile->pOpen && pFile->pOpen->nLock ){
      /* If there are outstanding locks, do not actually close the file just
      ** yet because that would clear those locks.  Instead, add the file
      ** descriptor to pOpen->aPending.  It will be automatically closed when
      ** the last lock is cleared.
      */
      int *aNew;
      struct openCnt *pOpen = pFile->pOpen;
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105

  assert(LOCKING_STYLE_POSIX==1);
  assert(LOCKING_STYLE_FLOCK==2);
  assert(LOCKING_STYLE_DOTFILE==3);
  assert(LOCKING_STYLE_NONE==4);
  assert(LOCKING_STYLE_AFP==5);
  eLockingStyle = detectLockingStyle(pVfs, zFilename, h);
  pNew->pMethod = &aIoMethod[eLockingStyle-1];

  switch( eLockingStyle ){

    case LOCKING_STYLE_POSIX: {
      enterMutex();
      rc = findLockInfo(h, &pNew->pLock, &pNew->pOpen);
      leaveMutex();







<







2091
2092
2093
2094
2095
2096
2097

2098
2099
2100
2101
2102
2103
2104

  assert(LOCKING_STYLE_POSIX==1);
  assert(LOCKING_STYLE_FLOCK==2);
  assert(LOCKING_STYLE_DOTFILE==3);
  assert(LOCKING_STYLE_NONE==4);
  assert(LOCKING_STYLE_AFP==5);
  eLockingStyle = detectLockingStyle(pVfs, zFilename, h);


  switch( eLockingStyle ){

    case LOCKING_STYLE_POSIX: {
      enterMutex();
      rc = findLockInfo(h, &pNew->pLock, &pNew->pOpen);
      leaveMutex();
2148
2149
2150
2151
2152
2153
2154

2155
2156
2157
2158
2159
2160
2161
#endif
  }

  if( rc!=SQLITE_OK ){
    if( dirfd>=0 ) close(dirfd);
    close(h);
  }else{

    OpenCounter(+1);
  }
  return rc;
}

/*
** Open a file descriptor to the directory containing file zFilename.







>







2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
#endif
  }

  if( rc!=SQLITE_OK ){
    if( dirfd>=0 ) close(dirfd);
    close(h);
  }else{
    pNew->pMethod = &aIoMethod[eLockingStyle-1];
    OpenCounter(+1);
  }
  return rc;
}

/*
** Open a file descriptor to the directory containing file zFilename.