Skip to content

Commit

Permalink
added explicit lock drop in sessions tracking. Passing tests (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmwample authored Feb 17, 2021
1 parent dd2e1bc commit 9cf50ed
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/sessions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,10 @@ fn ingest_from_pubsub(map: Arc<RwLock<HashMap<String, u64>>>) {
},
None => {},
};

// Explicitly drop map write lock here (locks are automatically dropped
// when they fall out of scope but this is more clear.)
drop(mmap);
continue
}

Expand All @@ -373,7 +377,8 @@ fn ingest_from_pubsub(map: Arc<RwLock<HashMap<String, u64>>>) {
// Insert
*mmap.entry(key).or_insert(expire_time) = expire_time;

// Get rid of writable reference to map.
// Get rid of writable reference to map. (locks are automatically dropped
// when they fall out of scope but this is more clear.)
drop(mmap);

debug!("Added registered ip {} from redis", sd);
Expand Down

0 comments on commit 9cf50ed

Please sign in to comment.