Skip to content

Commit c98f92c

Browse files
committed
Avoid mutex for direct IO
1 parent 8861a9e commit c98f92c

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

CMakeLists.txt

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ project(HTTPFsExtension)
66

77
add_extension_definitions()
88

9-
include_directories(extension/httpfs/include ${DUCKDB_MODULE_BASE_DIR}/third_party/httplib)
9+
include_directories(extension/httpfs/include
10+
${DUCKDB_MODULE_BASE_DIR}/third_party/httplib)
1011

1112
build_static_extension(
1213
httpfs
@@ -38,16 +39,17 @@ endif()
3839
find_package(OpenSSL REQUIRED)
3940
include_directories(${OPENSSL_INCLUDE_DIR})
4041
if(EMSCRIPTEN)
41-
else()
42-
target_link_libraries(httpfs_loadable_extension duckdb_mbedtls
43-
${OPENSSL_LIBRARIES})
44-
target_link_libraries(httpfs_extension duckdb_mbedtls ${OPENSSL_LIBRARIES})
4542

46-
if(MINGW)
47-
find_package(ZLIB)
48-
target_link_libraries(httpfs_loadable_extension ZLIB::ZLIB -lcrypt32)
49-
target_link_libraries(httpfs_extension ZLIB::ZLIB -lcrypt32)
50-
endif()
43+
else()
44+
target_link_libraries(httpfs_loadable_extension duckdb_mbedtls
45+
${OPENSSL_LIBRARIES})
46+
target_link_libraries(httpfs_extension duckdb_mbedtls ${OPENSSL_LIBRARIES})
47+
48+
if(MINGW)
49+
find_package(ZLIB)
50+
target_link_libraries(httpfs_loadable_extension ZLIB::ZLIB -lcrypt32)
51+
target_link_libraries(httpfs_extension ZLIB::ZLIB -lcrypt32)
52+
endif()
5153
endif()
5254

5355
install(

extension/httpfs/httpfs.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,14 @@ void HTTPFileSystem::Read(FileHandle &handle, void *buffer, int64_t nr_bytes, id
515515
if (skip_buffer && to_read > 0) {
516516
GetRangeRequest(hfh, hfh.path, {}, location, (char *)buffer, to_read);
517517

518-
std::lock_guard<std::mutex> lck(hfh.mu);
518+
// Update handle status within critical section for parallel access.
519+
if (hfh.flags.RequireParallelAccess()) {
520+
std::lock_guard<std::mutex> lck(hfh.mu);
521+
hfh.buffer_available = 0;
522+
hfh.buffer_idx = 0;
523+
return;
524+
}
525+
519526
hfh.buffer_available = 0;
520527
hfh.buffer_idx = 0;
521528
return;

0 commit comments

Comments
 (0)