Skip to content

Commit def64c2

Browse files
committed
fix up thread safety
1 parent 4dd1096 commit def64c2

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/accountsdb/account_store.zig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ pub const ThreadSafeAccountMap = struct {
263263
pub fn getLatest(self: *ThreadSafeAccountMap, address: Pubkey) !?Account {
264264
self.rwlock.lockShared();
265265
defer self.rwlock.unlockShared();
266+
266267
const list = self.pubkey_map.get(address) orelse return null;
267268
if (list.items.len == 0) return null;
268269
return asAccount(list.items[0][1]);
@@ -284,6 +285,9 @@ pub const ThreadSafeAccountMap = struct {
284285
address: Pubkey,
285286
put_account: AccountSharedData,
286287
) !void {
288+
self.rwlock.lock();
289+
defer self.rwlock.unlock();
290+
287291
const account = try put_account.clone(self.allocator);
288292

289293
slot_map: {

0 commit comments

Comments
 (0)