From 157ff98a485cdd2c5cedd0ef41c57f4a115e9108 Mon Sep 17 00:00:00 2001 From: flynn Date: Wed, 6 Nov 2024 10:31:39 +0000 Subject: [PATCH 1/2] Avoid unlock twice when io_setup failed --- src/linux_aligned_file_reader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/linux_aligned_file_reader.cpp b/src/linux_aligned_file_reader.cpp index 31bf5f827..4eb3ff38a 100644 --- a/src/linux_aligned_file_reader.cpp +++ b/src/linux_aligned_file_reader.cpp @@ -160,8 +160,8 @@ void LinuxAlignedFileReader::register_thread() { diskann::cout << "allocating ctx: " << ctx << " to thread-id:" << my_id << std::endl; ctx_map[my_id] = ctx; + lk.unlock(); } - lk.unlock(); } void LinuxAlignedFileReader::deregister_thread() From cd0e7d756eabba102f77cdbe4e39fbcbde1f4613 Mon Sep 17 00:00:00 2001 From: flynn Date: Wed, 6 Nov 2024 10:41:39 +0000 Subject: [PATCH 2/2] explicit unlock is unneeded --- src/linux_aligned_file_reader.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/linux_aligned_file_reader.cpp b/src/linux_aligned_file_reader.cpp index 4eb3ff38a..067e3647a 100644 --- a/src/linux_aligned_file_reader.cpp +++ b/src/linux_aligned_file_reader.cpp @@ -146,7 +146,6 @@ void LinuxAlignedFileReader::register_thread() int ret = io_setup(MAX_EVENTS, &ctx); if (ret != 0) { - lk.unlock(); if (ret == -EAGAIN) { std::cerr << "io_setup() failed with EAGAIN: Consider increasing /proc/sys/fs/aio-max-nr" << std::endl; @@ -160,7 +159,6 @@ void LinuxAlignedFileReader::register_thread() { diskann::cout << "allocating ctx: " << ctx << " to thread-id:" << my_id << std::endl; ctx_map[my_id] = ctx; - lk.unlock(); } }