Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Clean up comments in os_unix.c. (CVS 2950) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
2170e803ad48cffa6dddf8b591e0c085 |
User & Date: | drh 2006-01-15 17:27:18.000 |
Context
2006-01-15
| ||
18:29 | Prepare for the 3.3.1 alpha release. (CVS 2951) (check-in: 3e32bcf0b8 user: drh tags: trunk) | |
17:27 | Clean up comments in os_unix.c. (CVS 2950) (check-in: 2170e803ad user: drh tags: trunk) | |
14:11 | Correctly set the length of the string in bytes when transforming an OP_String8 to OP_String in a utf-16 vdbe program. (CVS 2949) (check-in: 69f996e0fa user: danielk1977 tags: trunk) | |
Changes
Changes to src/os_unix.c.
︙ | |||
15 16 17 18 19 20 21 | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | - + - - | #include "sqliteInt.h" #include "os.h" #if OS_UNIX /* This file is used on unix only */ /* ** These #defines should enable >2GB file support on Posix if the ** underlying operating system supports it. If the OS lacks |
︙ | |||
47 48 49 50 51 52 53 | 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | - - + + - - | #include <fcntl.h> #include <unistd.h> #include <time.h> #include <sys/time.h> #include <errno.h> /* |
︙ | |||
81 82 83 84 85 86 87 | 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | - + | struct lockInfo *pLock; /* Info about locks on this inode */ 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 */ unsigned char fullSync; /* Use F_FULLSYNC if available */ int dirfd; /* File descriptor for the directory */ #ifdef SQLITE_UNIX_THREADS |
︙ | |||
109 110 111 112 113 114 115 | 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | - + | /* ** Include code that is common to all os_*.c files */ #include "os_common.h" /* ** Do not include any of the File I/O interface procedures if the |
︙ | |||
160 161 162 163 164 165 166 167 168 169 170 171 172 173 | 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | + + + + + + + | ** Set or check the OsFile.tid field. This field is set when an OsFile ** is first opened. All subsequent uses of the OsFile verify that the ** same thread is operating on the OsFile. Some operating systems do ** not allow locks to be overridden by other threads and that restriction ** means that sqlite3* database handles cannot be moved from one thread ** to another. This logic makes sure a user does not try to do that ** by mistake. ** ** Version 3.3.1 (2006-01-15): OsFiles can be moved from one thread to ** another as long as we are running on a system that supports threads ** overriding each others locks (which now the most common behavior) ** or if no locks are held. But the OsFile.pLock field needs to be ** recomputed because its key includes the thread-id. See the ** transferOwnership() function below for additional information */ #if defined(SQLITE_UNIX_THREADS) # define SET_THREADID(X) (X)->tid = pthread_self() # define CHECK_THREADID(X) (threadsOverrideEachOthersLocks==0 && \ !pthread_equal((X)->tid, pthread_self())) #else # define SET_THREADID(X) |
︙ | |||
276 277 278 279 280 281 282 | 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | - - + + | /* ** An instance of the following structure serves as the key used ** to locate a particular lockInfo structure given its inode. ** ** If threads cannot override each others locks, then we set the ** lockKey.tid field to the thread ID. If threads can override |
︙ | |||
329 330 331 332 333 334 335 | 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 | + - - + + + + + + | int nRef; /* Number of pointers to this structure */ int nLock; /* Number of outstanding locks */ int nPending; /* Number of pending close() operations */ int *aPending; /* Malloced space holding fd's awaiting a close() */ }; /* ** These hash tables map inodes and file descriptors (really, lockKey and |
︙ | |||
368 369 370 371 372 373 374 | 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 | - + | #ifdef SQLITE_LOCK_TRACE /* ** Print out information about all locking operations. ** ** This routine is used for troubleshooting locks on multithreaded ** platforms. Enable by compiling with the -DSQLITE_LOCK_TRACE ** command-line option on the compiler. This code is normally |
︙ | |||
606 607 608 609 610 611 612 | 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 | - + | ** ** A unixFile is only owned by a thread on systems where one thread is ** unable to override locks created by a different thread. RedHat9 is ** an example of such a system. ** ** Ownership transfer is only allowed if the unixFile is currently unlocked. ** If the unixFile is locked and an ownership is wrong, then return |
︙ | |||
636 637 638 639 640 641 642 643 644 645 646 647 648 649 | 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 | + | rc = findLockInfo(pFile->h, &pFile->pLock, 0); TRACE5("LOCK %d is now %s(%s,%d)\n", pFile->h, locktypeName(pFile->locktype), locktypeName(pFile->pLock->locktype), pFile->pLock->cnt); return rc; } #else /* On single-threaded builds, ownership transfer is a no-op */ # define transferOwnership(X) SQLITE_OK #endif /* ** Delete the named file */ int sqlite3UnixDelete(const char *zFilename){ |
︙ | |||
830 831 832 833 834 835 836 837 838 839 840 841 842 843 | 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 | + + | return SQLITE_OK; } /* ** If the following global variable points to a string which is the ** name of a directory, then that directory will be used to store ** temporary files. ** ** See also the "PRAGMA temp_store_directory" SQL command. */ char *sqlite3_temp_directory = 0; /* ** Create a temporary file name in zBuf. zBuf must be big enough to ** hold at least SQLITE_TEMPNAME_SIZE characters. */ |
︙ | |||
1367 1368 1369 1370 1371 1372 1373 | 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 | - - - - - + + + | /* ** Lower the locking level on file descriptor pFile to locktype. locktype ** must be either NO_LOCK or SHARED_LOCK. ** ** If the locking level of the file descriptor is already at or below ** the requested locking level, this routine is a no-op. |
︙ | |||
1612 1613 1614 1615 1616 1617 1618 | 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 | - + | ** prefer that the randomness be increased by making use of the ** uninitialized space in zBuf - but valgrind errors tend to worry ** some users. Rather than argue, it seems easier just to initialize ** the whole array and silence valgrind, even if that means less randomness ** in the random seed. ** ** When testing, initializing zBuf[] to zero is all we do. That means |
︙ | |||
1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 | 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 | + | } #endif return SQLITE_OK; } /* ** Sleep for a little while. Return the amount of time slept. ** The argument is the number of milliseconds we want to sleep. */ int sqlite3UnixSleep(int ms){ #if defined(HAVE_USLEEP) && HAVE_USLEEP usleep(ms*1000); return ms; #else sleep((ms+999)/1000); |
︙ | |||
1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 | 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 | + + | /* ** The following pair of routine implement mutual exclusion for ** multi-threaded processes. Only a single thread is allowed to ** executed code that is surrounded by EnterMutex() and LeaveMutex(). ** ** SQLite uses only a single Mutex. There is not much critical ** code and what little there is executes quickly and without blocking. ** ** This mutex is not recursive. */ void sqlite3UnixEnterMutex(){ #ifdef SQLITE_UNIX_THREADS pthread_mutex_lock(&mutex); #endif assert( !inMutex ); inMutex = 1; |
︙ | |||
1708 1709 1710 1711 1712 1713 1714 | 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 | - + - + | # endif #else # define TSD_COUNTER(N) /* no-op */ #endif /* |
︙ |