@@ -144,7 +144,7 @@ RecSetRecord(RecT rec_type, const char *name, RecDataT data_type, RecData *data,
144144 // FIXME: Most of the time we set, we don't actually need to wrlock
145145 // since we are not modifying the g_records_ht.
146146 if (lock) {
147- ink_rwlock_wrlock (& g_records_rwlock);
147+ g_records_rwlock. lock ( );
148148 }
149149 if (auto it = g_records_ht.find (name); it != g_records_ht.end ()) {
150150 r1 = it->second ;
@@ -204,7 +204,7 @@ RecSetRecord(RecT rec_type, const char *name, RecDataT data_type, RecData *data,
204204
205205Ldone:
206206 if (lock) {
207- ink_rwlock_unlock (& g_records_rwlock);
207+ g_records_rwlock. unlock ( );
208208 }
209209
210210 return err;
@@ -284,7 +284,7 @@ RecReadStatsFile()
284284 ats_scoped_str snap_fpath (RecConfigReadPersistentStatsPath ());
285285
286286 // lock our hash table
287- ink_rwlock_wrlock (& g_records_rwlock);
287+ std::lock_guard lock ( g_records_rwlock);
288288
289289 CheckSnapFileVersion (snap_fpath);
290290
@@ -323,7 +323,6 @@ RecReadStatsFile()
323323 }
324324 }
325325
326- ink_rwlock_unlock (&g_records_rwlock);
327326 ats_free (m);
328327
329328 return REC_ERR_OKAY;
@@ -393,14 +392,11 @@ RecReadConfigFile()
393392 RecDebug (DL_Note, " Reading '%s'" , g_rec_config_fpath);
394393
395394 // lock our hash table
396- ink_rwlock_wrlock (& g_records_rwlock);
395+ std::lock_guard lock ( g_records_rwlock);
397396
398397 // Parse the actual file and hash the values.
399398 RecConfigFileParse (g_rec_config_fpath, RecConsumeConfigEntry);
400399
401- // release our hash table
402- ink_rwlock_unlock (&g_records_rwlock);
403-
404400 return REC_ERR_OKAY;
405401}
406402
@@ -410,12 +406,12 @@ RecReadYamlConfigFile()
410406 RecDebug (DL_Debug, " Reading '%s'" , g_rec_config_fpath);
411407
412408 // lock our hash table
413- ink_rwlock_wrlock (&g_records_rwlock); // review this lock maybe it should be done inside the API
409+ // review this lock maybe it should be done inside the API
410+ std::lock_guard lock (g_records_rwlock);
414411
415412 // Parse the actual file and hash the values.
416413 auto ret = RecYAMLConfigFileParse (g_rec_config_fpath, SetRecordFromYAMLNode);
417414
418- ink_rwlock_unlock (&g_records_rwlock);
419415 return ret;
420416}
421417
@@ -429,7 +425,7 @@ RecExecConfigUpdateCbs(unsigned int update_required_type)
429425 int i, num_records;
430426 RecUpdateT update_type = RECU_NULL;
431427
432- ink_rwlock_rdlock (& g_records_rwlock);
428+ ts::bravo::shared_lock lock ( g_records_rwlock);
433429
434430 num_records = g_num_records;
435431 for (i = 0 ; i < num_records; i++) {
@@ -463,8 +459,6 @@ RecExecConfigUpdateCbs(unsigned int update_required_type)
463459 rec_mutex_release (&(r->lock ));
464460 }
465461
466- ink_rwlock_unlock (&g_records_rwlock);
467-
468462 return update_type;
469463}
470464
@@ -540,7 +534,7 @@ RecSetSyncRequired(char *name, bool lock)
540534 // FIXME: Most of the time we set, we don't actually need to wrlock
541535 // since we are not modifying the g_records_ht.
542536 if (lock) {
543- ink_rwlock_wrlock (& g_records_rwlock);
537+ g_records_rwlock. lock ( );
544538 }
545539 if (auto it = g_records_ht.find (name); it != g_records_ht.end ()) {
546540 r1 = it->second ;
@@ -556,7 +550,7 @@ RecSetSyncRequired(char *name, bool lock)
556550 }
557551
558552 if (lock) {
559- ink_rwlock_unlock (& g_records_rwlock);
553+ g_records_rwlock. unlock ( );
560554 }
561555
562556 return err;
0 commit comments