Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix a race condtion in test_async.c. (CVS 4516) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
5e3f7c3dec3e8d92b28a74293387b390 |
User & Date: | danielk1977 2007-10-30 15:29:43.000 |
Context
2007-10-30
| ||
15:38 | Remove a debugging assert() that went in by accident with the previous commit. (CVS 4517) (check-in: 4ad60bdba0 user: danielk1977 tags: trunk) | |
15:29 | Fix a race condtion in test_async.c. (CVS 4516) (check-in: 5e3f7c3dec user: danielk1977 tags: trunk) | |
2007-10-27
| ||
16:25 | Clarify the behavior of sqlite3_last_insert_rowid() when using INSERT OR IGNORE. (CVS 4515) (check-in: c0fa0c8ba8 user: drh tags: trunk) | |
Changes
Changes to src/test_async.c.
︙ | ︙ | |||
1147 1148 1149 1150 1151 1152 1153 | ** and processing them in the order in which they arrive. ** ** An artifical delay of async.ioDelay milliseconds is inserted before ** each write operation in order to simulate the effect of a slow disk. ** ** Only one instance of this procedure may be running at a time. */ | | > | 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 | ** and processing them in the order in which they arrive. ** ** An artifical delay of async.ioDelay milliseconds is inserted before ** each write operation in order to simulate the effect of a slow disk. ** ** Only one instance of this procedure may be running at a time. */ static void *asyncWriterThread(void *pIsStarted){ sqlite3_vfs *pVfs = (sqlite3_vfs *)(async_vfs.pAppData); AsyncWrite *p = 0; int rc = SQLITE_OK; int holdingMutex = 0; if( pthread_mutex_trylock(&async.writerMutex) ){ return 0; } (*(int *)pIsStarted) = 1; while( async.writerHaltNow==0 ){ int doNotFree = 0; sqlite3_file *pBase = 0; if( !holdingMutex ){ pthread_mutex_lock(&async.queueMutex); } |
︙ | ︙ | |||
1469 1470 1471 1472 1473 1474 1475 | void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ pthread_t x; int rc; | > | > > > > | 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 | void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ pthread_t x; int rc; volatile int isStarted = 0; rc = pthread_create(&x, 0, asyncWriterThread, &isStarted); if( rc ){ Tcl_AppendResult(interp, "failed to create the thread", 0); return TCL_ERROR; } pthread_detach(x); while( isStarted==0 ){ sched_yield(); } return TCL_OK; } /* ** sqlite3async_wait ** ** Wait for the current writer thread to terminate. ** ** If the current writer thread is set to run forever then this ** command would block forever. To prevent that, an error is returned. */ static int testAsyncWait( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ int cnt = 10; assert(async.writerHaltNow==0); if( async.writerHaltNow==0 && async.writerHaltWhenIdle==0 ){ Tcl_AppendResult(interp, "would block forever", (char*)0); return TCL_ERROR; } while( cnt-- && !pthread_mutex_trylock(&async.writerMutex) ){ pthread_mutex_unlock(&async.writerMutex); |
︙ | ︙ |