2014-07-07 14:44 GMT+02:00 Andy Ling <andy.l...@quantel.com>:
> Removing the SQLITE_ENABLE_LOCKING_STYLE I get........
...
> sqlite3.c: In function 'fileHasMoved':
> sqlite3.c:25236: error: 'struct unixFileId' has no member named 'ino'
> sqlite3.c: In function 'semCheckReservedLock':
...
> sqlite3.c:26372: warning: unused variable 'statBuf'
> sqlite3.c: In function 'semLock':
...
> sqlite3.c:26425: warning: unused variable 'fd'

Below my suggested patch (derived from todays trunk)
which should solve the above 2 warnings and the
error. All other warnings/errors seems
to derive from the missing <semaphore.h> and maybe
other header files (<sys/mount.h> ???)

I don't have VxWorks, just tested this on Linux using
-DOS_VXWORKS=1, as suggested here:
    <www.sqlite.org/src/info/30a0132a83>

Apparently the function fileHasMoved (new in SQLite 3.8.3)
was never tested on VxWorks, otherwise it would have been
discovered that 'struct unixFileId' has different fields on VxWorks
compared to other UNIX platforms.

I hope this brings it a little bit closer to fully working on VxWorks.

Regards,
      Jan Nijtmans
Index: src/os_unix.c
==================================================================
--- src/os_unix.c
+++ src/os_unix.c
@@ -1301,13 +1301,19 @@

 /*
 ** Return TRUE if pFile has been renamed or unlinked since it was first opened.
 */
 static int fileHasMoved(unixFile *pFile){
+#if OS_VXWORKS
+  return pFile->pInode!=0 &&
+         (pFile->pId!=pFile->pInode->fileId.pId);
+
+#else
   struct stat buf;
   return pFile->pInode!=0 &&
          (osStat(pFile->zPath, &buf)!=0 ||
buf.st_ino!=pFile->pInode->fileId.ino);
+#endif
 }


 /*
 ** Check a unixFile that is a database.  Verify the following:
@@ -2446,11 +2452,10 @@
   }

   /* Otherwise see if some other process holds it. */
   if( !reserved ){
     sem_t *pSem = pFile->pInode->pSem;
-    struct stat statBuf;

     if( sem_trywait(pSem)==-1 ){
       int tErrno = errno;
       if( EAGAIN != tErrno ){
         rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_CHECKRESERVEDLOCK);
@@ -2499,11 +2504,10 @@
 ** This routine will only increase a lock.  Use the sqlite3OsUnlock()
 ** routine to lower a locking level.
 */
 static int semLock(sqlite3_file *id, int eFileLock) {
   unixFile *pFile = (unixFile*)id;
-  int fd;
   sem_t *pSem = pFile->pInode->pSem;
   int rc = SQLITE_OK;

   /* if we already have a lock, it is exclusive.
   ** Just adjust level and punt on outta here. */
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to