File tree Expand file tree Collapse file tree 6 files changed +57
-7
lines changed Expand file tree Collapse file tree 6 files changed +57
-7
lines changed Original file line number Diff line number Diff line change @@ -404,11 +404,13 @@ static void CompactifySimCollection (TRI_sim_collection_t* sim) {
404
404
size_t n ;
405
405
size_t i ;
406
406
407
+ if (! TRI_TRY_READ_LOCK_DATAFILES_SIM_COLLECTION (sim )) {
408
+ return ;
409
+ }
410
+
407
411
TRI_InitVector (& vector , TRI_UNKNOWN_MEM_ZONE , sizeof (TRI_doc_datafile_info_t ));
408
412
409
413
// copy datafile information
410
- TRI_READ_LOCK_DATAFILES_SIM_COLLECTION (sim );
411
-
412
414
n = sim -> base .base ._datafiles ._length ;
413
415
414
416
for (i = 0 ; i < n ; ++ i ) {
Original file line number Diff line number Diff line change @@ -52,6 +52,13 @@ extern "C" {
52
52
/// @{
53
53
////////////////////////////////////////////////////////////////////////////////
54
54
55
+ ////////////////////////////////////////////////////////////////////////////////
56
+ /// @brief tries to read lock the journal files and the parameter file
57
+ ////////////////////////////////////////////////////////////////////////////////
58
+
59
+ #define TRI_TRY_READ_LOCK_DATAFILES_SIM_COLLECTION (a ) \
60
+ TRI_TryReadLockReadWriteLock(&(a)->_lock)
61
+
55
62
////////////////////////////////////////////////////////////////////////////////
56
63
/// @brief read locks the journal files and the parameter file
57
64
////////////////////////////////////////////////////////////////////////////////
Original file line number Diff line number Diff line change @@ -138,7 +138,7 @@ static bool CheckJournalSimCollection (TRI_sim_collection_t* sim) {
138
138
bool worked ;
139
139
size_t i ;
140
140
size_t n ;
141
-
141
+
142
142
worked = false;
143
143
base = & sim -> base .base ;
144
144
@@ -205,7 +205,7 @@ static bool CheckSyncCompactorSimCollection (TRI_sim_collection_t* sim) {
205
205
double ti ;
206
206
size_t i ;
207
207
size_t n ;
208
-
208
+
209
209
worked = false;
210
210
base = & sim -> base .base ;
211
211
@@ -266,7 +266,7 @@ static bool CheckCompactorSimCollection (TRI_sim_collection_t* sim) {
266
266
bool worked ;
267
267
size_t i ;
268
268
size_t n ;
269
-
269
+
270
270
worked = false;
271
271
base = & sim -> base .base ;
272
272
@@ -365,8 +365,10 @@ void TRI_SynchroniserVocBase (void* data) {
365
365
bool result ;
366
366
367
367
collection = collections ._buffer [i ];
368
-
369
- TRI_READ_LOCK_STATUS_VOCBASE_COL (collection );
368
+
369
+ if (! TRI_TRY_READ_LOCK_DATAFILES_SIM_COLLECTION (collection )) {
370
+ continue ;
371
+ }
370
372
371
373
if (collection -> _status != TRI_VOC_COL_STATUS_LOADED ) {
372
374
TRI_READ_UNLOCK_STATUS_VOCBASE_COL (collection );
Original file line number Diff line number Diff line change @@ -229,6 +229,18 @@ void TRI_DestroyReadWriteLock (TRI_read_write_lock_t* lock) {
229
229
/// @{
230
230
////////////////////////////////////////////////////////////////////////////////
231
231
232
+ ////////////////////////////////////////////////////////////////////////////////
233
+ /// @brief tries to read lock read-write lock
234
+ ////////////////////////////////////////////////////////////////////////////////
235
+
236
+ bool TRI_TryReadLockReadWriteLock (TRI_read_write_lock_t * lock ) {
237
+ int rc ;
238
+
239
+ rc = pthread_rwlock_tryrdlock (lock );
240
+
241
+ return (rc == 0 );
242
+ }
243
+
232
244
////////////////////////////////////////////////////////////////////////////////
233
245
/// @brief read locks read-write lock
234
246
////////////////////////////////////////////////////////////////////////////////
Original file line number Diff line number Diff line change @@ -266,6 +266,27 @@ static void DecrementReaders (TRI_read_write_lock_t* lock) {
266
266
/// @{
267
267
////////////////////////////////////////////////////////////////////////////////
268
268
269
+ ////////////////////////////////////////////////////////////////////////////////
270
+ /// @brief tries to read lock a read-write lock
271
+ ////////////////////////////////////////////////////////////////////////////////
272
+
273
+ bool TRI_TryReadLockReadWriteLock (TRI_read_write_lock_t * lock ) {
274
+ WaitForSingleObject (lock -> _writerEvent , 10 ); // 10 millis timeout
275
+
276
+ EnterCriticalSection (& lock -> _lockReaders );
277
+ IncrementReaders (lock );
278
+ LeaveCriticalSection (& lock -> _lockReaders );
279
+
280
+ if (WaitForSingleObject (lock -> _writerEvent , 0 ) != WAIT_OBJECT_0 ) {
281
+ EnterCriticalSection (& lock -> _lockReaders );
282
+ DecrementReaders (lock );
283
+ LeaveCriticalSection (& lock -> _lockReaders );
284
+ return false;
285
+ }
286
+
287
+ return true;
288
+ }
289
+
269
290
////////////////////////////////////////////////////////////////////////////////
270
291
/// @brief read locks read-write lock
271
292
////////////////////////////////////////////////////////////////////////////////
Original file line number Diff line number Diff line change @@ -228,6 +228,12 @@ void TRI_DestroyReadWriteLock (TRI_read_write_lock_t* lock);
228
228
/// @{
229
229
////////////////////////////////////////////////////////////////////////////////
230
230
231
+ ////////////////////////////////////////////////////////////////////////////////
232
+ /// @brief tries to read lock read-write lock
233
+ ////////////////////////////////////////////////////////////////////////////////
234
+
235
+ bool TRI_TryReadLockReadWriteLock (TRI_read_write_lock_t * lock );
236
+
231
237
////////////////////////////////////////////////////////////////////////////////
232
238
/// @brief read locks read-write lock
233
239
////////////////////////////////////////////////////////////////////////////////
You can’t perform that action at this time.
0 commit comments