/ Check-in [1786e9c8]
Login

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

Overview
Comment:Remove the unixFile.isOpen variable (no longer in use). (CVS 4401)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:1786e9c881a67fbf8bd014d643590534c8c601dc
User & Date: danielk1977 2007-09-05 13:56:32
Context
2007-09-05
14:30
Restore the sqlite3_mutex_try() optimization on winNT systems. (CVS 4402) check-in: 3aace2fa user: drh tags: trunk
13:56
Remove the unixFile.isOpen variable (no longer in use). (CVS 4401) check-in: 1786e9c8 user: danielk1977 tags: trunk
11:34
Fix a problem in the test scripts for the asynchronous backend. (CVS 4400) check-in: 630fc71f user: danielk1977 tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/os_unix.c.

92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
....
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
....
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
....
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
....
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
....
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
  struct openCnt *pOpen;    /* Info about all open fd's on this inode */
  struct lockInfo *pLock;   /* Info about locks on this inode */
#ifdef SQLITE_ENABLE_LOCKING_STYLE
  void *lockingContext;     /* Locking style specific state */
#endif /* SQLITE_ENABLE_LOCKING_STYLE */
  int h;                    /* The file descriptor */
  unsigned char locktype;   /* The type of lock held on this fd */
  unsigned char isOpen;     /* True if needs to be closed */
  int dirfd;                /* File descriptor for the directory */
#if SQLITE_THREADSAFE
  pthread_t tid;            /* The thread that "owns" this unixFile */
#endif
};

/*
................................................................................
    /* There are no outstanding locks so we can close the file immediately */
    close(pFile->h);
  }
  releaseLockInfo(pFile->pLock);
  releaseOpenCnt(pFile->pOpen);

  leaveMutex();
  pFile->isOpen = 0;
  OSTRACE2("CLOSE   %-3d\n", pFile->h);
  OpenCounter(-1);
  memset(pFile, 0, sizeof(unixFile));
  return SQLITE_OK;
}


................................................................................
      sqlite3_free(((afpLockingContext*)pFile->lockingContext)->filePath);
    sqlite3_free(pFile->lockingContext);
  }

  if( pFile->dirfd>=0 ) close(pFile->dirfd);
  pFile->dirfd = -1;
  close(pFile->h);
  pFile->isOpen = 0;
  OSTRACE2("CLOSE   %-3d\n", pFile->h);
  OpenCounter(-1);
  return SQLITE_OK;
}


#pragma mark flock() style locking
................................................................................
  
  if( pFile->dirfd>=0 ) close(pFile->dirfd);
  pFile->dirfd = -1;
  enterMutex();
  
  close(pFile->h);  
  leaveMutex();
  pFile->isOpen = 0;
  OSTRACE2("CLOSE   %-3d\n", pFile->h);
  OpenCounter(-1);
  return SQLITE_OK;
}

#pragma mark Old-School .lock file based locking

................................................................................
  if( pFile->dirfd>=0 ) close(pFile->dirfd);
  pFile->dirfd = -1;
  enterMutex();
  
  close(pFile->h);
  
  leaveMutex();
  pFile->isOpen = 0;
  OSTRACE2("CLOSE   %-3d\n", pFile->h);
  OpenCounter(-1);
  return SQLITE_OK;
}


#pragma mark No locking
................................................................................
  if( pFile->dirfd>=0 ) close(pFile->dirfd);
  pFile->dirfd = -1;
  enterMutex();
  
  close(pFile->h);
  
  leaveMutex();
  pFile->isOpen = 0;
  OSTRACE2("CLOSE   %-3d\n", pFile->h);
  OpenCounter(-1);
  return SQLITE_OK;
}

#endif /* SQLITE_ENABLE_LOCKING_STYLE */








<







 







<







 







<







 







<







 







<







 







<







92
93
94
95
96
97
98

99
100
101
102
103
104
105
....
1429
1430
1431
1432
1433
1434
1435

1436
1437
1438
1439
1440
1441
1442
....
1749
1750
1751
1752
1753
1754
1755

1756
1757
1758
1759
1760
1761
1762
....
1842
1843
1844
1845
1846
1847
1848

1849
1850
1851
1852
1853
1854
1855
....
1958
1959
1960
1961
1962
1963
1964

1965
1966
1967
1968
1969
1970
1971
....
1997
1998
1999
2000
2001
2002
2003

2004
2005
2006
2007
2008
2009
2010
  struct openCnt *pOpen;    /* Info about all open fd's on this inode */
  struct lockInfo *pLock;   /* Info about locks on this inode */
#ifdef SQLITE_ENABLE_LOCKING_STYLE
  void *lockingContext;     /* Locking style specific state */
#endif /* SQLITE_ENABLE_LOCKING_STYLE */
  int h;                    /* The file descriptor */
  unsigned char locktype;   /* The type of lock held on this fd */

  int dirfd;                /* File descriptor for the directory */
#if SQLITE_THREADSAFE
  pthread_t tid;            /* The thread that "owns" this unixFile */
#endif
};

/*
................................................................................
    /* There are no outstanding locks so we can close the file immediately */
    close(pFile->h);
  }
  releaseLockInfo(pFile->pLock);
  releaseOpenCnt(pFile->pOpen);

  leaveMutex();

  OSTRACE2("CLOSE   %-3d\n", pFile->h);
  OpenCounter(-1);
  memset(pFile, 0, sizeof(unixFile));
  return SQLITE_OK;
}


................................................................................
      sqlite3_free(((afpLockingContext*)pFile->lockingContext)->filePath);
    sqlite3_free(pFile->lockingContext);
  }

  if( pFile->dirfd>=0 ) close(pFile->dirfd);
  pFile->dirfd = -1;
  close(pFile->h);

  OSTRACE2("CLOSE   %-3d\n", pFile->h);
  OpenCounter(-1);
  return SQLITE_OK;
}


#pragma mark flock() style locking
................................................................................
  
  if( pFile->dirfd>=0 ) close(pFile->dirfd);
  pFile->dirfd = -1;
  enterMutex();
  
  close(pFile->h);  
  leaveMutex();

  OSTRACE2("CLOSE   %-3d\n", pFile->h);
  OpenCounter(-1);
  return SQLITE_OK;
}

#pragma mark Old-School .lock file based locking

................................................................................
  if( pFile->dirfd>=0 ) close(pFile->dirfd);
  pFile->dirfd = -1;
  enterMutex();
  
  close(pFile->h);
  
  leaveMutex();

  OSTRACE2("CLOSE   %-3d\n", pFile->h);
  OpenCounter(-1);
  return SQLITE_OK;
}


#pragma mark No locking
................................................................................
  if( pFile->dirfd>=0 ) close(pFile->dirfd);
  pFile->dirfd = -1;
  enterMutex();
  
  close(pFile->h);
  
  leaveMutex();

  OSTRACE2("CLOSE   %-3d\n", pFile->h);
  OpenCounter(-1);
  return SQLITE_OK;
}

#endif /* SQLITE_ENABLE_LOCKING_STYLE */

Changes to test/async.test.

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
..
22
23
24
25
26
27
28






29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file runs all tests.
#
# $Id: async.test,v 1.10 2007/09/05 11:34:54 danielk1977 Exp $


if {[catch {sqlite3async_enable}]} {
  # The async logic is not built into this system
  return
}

................................................................................
  catch {db close}
  catch {db2 close}
  catch {db3 close}
}
set ISQUICK 1

set INCLUDE {






  select1.test
  select2.test
  select3.test
  select4.test
  insert.test
  insert2.test
  insert3.test
  trans.test
  lock.test
  lock3.test
  lock2.test
}

# Enable asynchronous IO.
sqlite3async_enable 1

rename do_test really_do_test
proc do_test {name args} {
  uplevel really_do_test async_io-$name $args
  sqlite3async_halt idle
  sqlite3async_start
  sqlite3async_wait
}

foreach testfile [lsort -dictionary [glob $testdir/*.test]] {
  set tail [file tail $testfile]
  if {[lsearch -exact $INCLUDE $tail]<0} continue
  source $testfile







|







 







>
>
>
>
>
>




<
<
<

<
<
<








|
|







2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
..
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38



39



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file runs all tests.
#
# $Id: async.test,v 1.11 2007/09/05 13:56:32 danielk1977 Exp $


if {[catch {sqlite3async_enable}]} {
  # The async logic is not built into this system
  return
}

................................................................................
  catch {db close}
  catch {db2 close}
  catch {db3 close}
}
set ISQUICK 1

set INCLUDE {
  insert.test
  insert2.test
  insert3.test
  lock.test
  lock2.test
  lock3.test
  select1.test
  select2.test
  select3.test
  select4.test



  trans.test



}

# Enable asynchronous IO.
sqlite3async_enable 1

rename do_test really_do_test
proc do_test {name args} {
  uplevel really_do_test async_io-$name $args
  sqlite3async_start
  sqlite3async_halt idle
  sqlite3async_wait
}

foreach testfile [lsort -dictionary [glob $testdir/*.test]] {
  set tail [file tail $testfile]
  if {[lsearch -exact $INCLUDE $tail]<0} continue
  source $testfile

Changes to test/lock4.test.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
..
79
80
81
82
83
84
85

86
87
88
89
90
91
92
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this script is database locks.
#
# $Id: lock4.test,v 1.4 2007/04/06 21:42:22 drh Exp $


set testdir [file dirname $argv0]
source $testdir/tester.tcl

# Initialize the test.db database so that it is non-empty
#
................................................................................
    INSERT INTO t2 VALUES(1)
  } db2
} {1 {database is locked}}
do_test lock4-1.3 {
  db eval {
     COMMIT;
  }

  while {[file exists test2.db-journal]} {
    after 10
  }
  db2 eval {
     SELECT * FROM t2
  }
} {2}







|







 







>







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
..
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this script is database locks.
#
# $Id: lock4.test,v 1.5 2007/09/05 13:56:32 danielk1977 Exp $


set testdir [file dirname $argv0]
source $testdir/tester.tcl

# Initialize the test.db database so that it is non-empty
#
................................................................................
    INSERT INTO t2 VALUES(1)
  } db2
} {1 {database is locked}}
do_test lock4-1.3 {
  db eval {
     COMMIT;
  }
breakpoint
  while {[file exists test2.db-journal]} {
    after 10
  }
  db2 eval {
     SELECT * FROM t2
  }
} {2}