Prepare to revert WebKit patch http://trac.webkit.org/changeset/68310 because...

Prepare to revert WebKit patch http://trac.webkit.org/changeset/68310 because of stability issues (race conditions detected by tsan, possibly leading to crashes).

Revert "Update sqlite's README.chromium with a note to keep webkit side" (http://crrev.com/62151).

Revert "Remove our local modifications to sqlite's os_unix.c now that" (http://crrev.com/60761).

BUG=70589, 22208
TEST=none

Review URL: http://codereview.chromium.org/6330011

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72673 0039d316-1c4b-4281-b951-d872f2087c98
parent 20477755
...@@ -42,11 +42,6 @@ cd sqlite ...@@ -42,11 +42,6 @@ cd sqlite
# Run the google_generate_preprocessed.sh script: # Run the google_generate_preprocessed.sh script:
./google_generate_preprocessed.sh ./google_generate_preprocessed.sh
# If there are any updates to os_unix.c, remember to keep
# WebCore/platform/sql/chromium/SQLiteFileSystemChromiumPosix.cpp in sync.
# This means preparing a separate patch for WebKit.
# If you have questions about this part, ask phajdan.jr and dumi.
# Find a sucker. Send review. # Find a sucker. Send review.
# TODO(shess) Describe an appropriate comment style. Seems like it # TODO(shess) Describe an appropriate comment style. Seems like it
# should at least include the SQLite version number. # should at least include the SQLite version number.
...@@ -160,3 +155,18 @@ Changes from Chrome: ...@@ -160,3 +155,18 @@ Changes from Chrome:
- Added a new function chromium_sqlite3_initialize_win_sqlite3_file() - Added a new function chromium_sqlite3_initialize_win_sqlite3_file()
at the end of os_win.c. It allows the Windows-specific Chromium VFS at the end of os_win.c. It allows the Windows-specific Chromium VFS
to reuse most of the win32 SQLite VFS. to reuse most of the win32 SQLite VFS.
- Added a new function
chromium_sqlite3_initialize_unix_sqlite3_file() and made
fillInUnixFile() non-static in os_unix.c. It allows the
Linux-specific Chromium VFS to reuse most of the unix SQLite VFS.
- Exposed three functions that deal with unused file descriptors in
os_unix.c, to allow Chromium's Posix VFS implementation in
WebKit/WebCore/platform/sql/chromium/SQLiteFileSystemChromiumPosix.cpp
to correctly implement the "unused file descriptors" logic in the
xDlOpen() method. The new functions are
chromium_sqlite3_get_reusable_file_handle(),
chromium_sqlite3_update_reusable_file_handle() and
chromium_sqlite3_destroy_reusable_file_handle(). Also, added the
chromium_sqlite3_fill_in_unix_sqlite3_file() function that calls
fillInUnixFile(), which will be made static again as soon as a
WebKit patch using the new function lands.
...@@ -3229,6 +3229,7 @@ static int unixDeviceCharacteristics(sqlite3_file *NotUsed){ ...@@ -3229,6 +3229,7 @@ static int unixDeviceCharacteristics(sqlite3_file *NotUsed){
********************** End sqlite3_file Methods ******************************* ********************** End sqlite3_file Methods *******************************
******************************************************************************/ ******************************************************************************/
/* /*
** This division contains definitions of sqlite3_io_methods objects that ** This division contains definitions of sqlite3_io_methods objects that
** implement various file locking strategies. It also contains definitions ** implement various file locking strategies. It also contains definitions
...@@ -3825,6 +3826,73 @@ static UnixUnusedFd *findReusableFd(const char *zPath, int flags){ ...@@ -3825,6 +3826,73 @@ static UnixUnusedFd *findReusableFd(const char *zPath, int flags){
return pUnused; return pUnused;
} }
/*
** Initializes a unixFile structure with zeros.
*/
void chromium_sqlite3_initialize_unix_sqlite3_file(sqlite3_file* file) {
memset(file, 0, sizeof(unixFile));
}
int chromium_sqlite3_fill_in_unix_sqlite3_file(sqlite3_vfs* vfs,
int fd,
int dirfd,
sqlite3_file* file,
const char* fileName,
int noLock,
int isDelete) {
return fillInUnixFile(vfs, fd, dirfd, file, fileName, noLock, isDelete);
}
/*
** Search for an unused file descriptor that was opened on the database file.
** If a suitable file descriptor if found, then it is stored in *fd; otherwise,
** *fd is not modified.
**
** If a reusable file descriptor is not found, and a new UnixUnusedFd cannot
** be allocated, SQLITE_NOMEM is returned. Otherwise, SQLITE_OK is returned.
*/
int chromium_sqlite3_get_reusable_file_handle(sqlite3_file* file,
const char* fileName,
int flags,
int* fd) {
unixFile* unixSQLite3File = (unixFile*)file;
int fileType = flags & 0xFFFFFF00;
if (fileType == SQLITE_OPEN_MAIN_DB) {
UnixUnusedFd *unusedFd = findReusableFd(fileName, flags);
if (unusedFd) {
*fd = unusedFd->fd;
} else {
unusedFd = sqlite3_malloc(sizeof(*unusedFd));
if (!unusedFd) {
return SQLITE_NOMEM;
}
}
unixSQLite3File->pUnused = unusedFd;
}
return SQLITE_OK;
}
/*
** Marks 'fd' as the unused file descriptor for 'pFile'.
*/
void chromium_sqlite3_update_reusable_file_handle(sqlite3_file* file,
int fd,
int flags) {
unixFile* unixSQLite3File = (unixFile*)file;
if (unixSQLite3File->pUnused) {
unixSQLite3File->pUnused->fd = fd;
unixSQLite3File->pUnused->flags = flags;
}
}
/*
** Destroys pFile's field that keeps track of the unused file descriptor.
*/
void chromium_sqlite3_destroy_reusable_file_handle(sqlite3_file* file) {
unixFile* unixSQLite3File = (unixFile*)file;
sqlite3_free(unixSQLite3File->pUnused);
}
/* /*
** Open the file zPath. ** Open the file zPath.
** **
...@@ -3907,20 +3975,13 @@ static int unixOpen( ...@@ -3907,20 +3975,13 @@ static int unixOpen(
|| eType==SQLITE_OPEN_TRANSIENT_DB || eType==SQLITE_OPEN_TRANSIENT_DB
); );
memset(p, 0, sizeof(unixFile)); chromium_sqlite3_initialize_unix_sqlite3_file(pFile);
if( eType==SQLITE_OPEN_MAIN_DB ){ if( eType==SQLITE_OPEN_MAIN_DB ){
UnixUnusedFd *pUnused; rc = chromium_sqlite3_get_reusable_file_handle(pFile, zName, flags, &fd);
pUnused = findReusableFd(zName, flags); if( rc!=SQLITE_OK ){
if( pUnused ){ return rc;
fd = pUnused->fd;
}else{
pUnused = sqlite3_malloc(sizeof(*pUnused));
if( !pUnused ){
return SQLITE_NOMEM;
}
} }
p->pUnused = pUnused;
}else if( !zName ){ }else if( !zName ){
/* If zName is NULL, the upper layer is requesting a temp file. */ /* If zName is NULL, the upper layer is requesting a temp file. */
assert(isDelete && !isOpenDirectory); assert(isDelete && !isOpenDirectory);
...@@ -3963,10 +4024,7 @@ static int unixOpen( ...@@ -3963,10 +4024,7 @@ static int unixOpen(
*pOutFlags = flags; *pOutFlags = flags;
} }
if( p->pUnused ){ chromium_sqlite3_update_reusable_file_handle(pFile, fd, flags);
p->pUnused->fd = fd;
p->pUnused->flags = flags;
}
if( isDelete ){ if( isDelete ){
#if OS_VXWORKS #if OS_VXWORKS
...@@ -4038,11 +4096,11 @@ static int unixOpen( ...@@ -4038,11 +4096,11 @@ static int unixOpen(
} }
} }
#endif #endif
rc = fillInUnixFile(pVfs, fd, dirfd, pFile, zPath, noLock, isDelete); rc = fillInUnixFile(pVfs, fd, dirfd, pFile, zPath, noLock, isDelete);
open_finished: open_finished:
if( rc!=SQLITE_OK ){ if( rc!=SQLITE_OK ){
sqlite3_free(p->pUnused); chromium_sqlite3_destroy_reusable_file_handle(pFile);
} }
return rc; return rc;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment