Skip to content

Commit d85aeae

Browse files
committed
close index file fd only if index is not build via socket
1 parent 96f2c24 commit d85aeae

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.3)
22
include(CheckSymbolExists)
33

4-
set(LANTERN_VERSION 0.3.2)
4+
set(LANTERN_VERSION 0.3.3)
55

66
project(
77
LanternDB
@@ -263,6 +263,7 @@ endif()
263263
set (_update_files
264264
sql/updates/0.3.0--0.3.1.sql
265265
sql/updates/0.3.1--0.3.2.sql
266+
sql/updates/0.3.2--0.3.3.sql
266267
)
267268

268269
# Generate version information for the binary

sql/updates/0.3.2--0.3.3.sql

Whitespace-only changes.

src/hnsw/build.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,7 @@ static void BuildIndex(Relation heap, Relation index, IndexInfo *indexInfo, ldb_
552552

553553
if(buildstate->index_file_path) {
554554
index_file_fd = open(buildstate->index_file_path, O_RDONLY);
555+
assert(index_file_fd > 0);
555556
} else if(buildstate->external) {
556557
external_index_receive_index_file(buildstate->external_socket, &num_added_vectors, &result_buf);
557558
} else {
@@ -565,10 +566,9 @@ static void BuildIndex(Relation heap, Relation index, IndexInfo *indexInfo, ldb_
565566
usearch_save(buildstate->usearch_index, tmp_index_file_path, &error);
566567
assert(error == NULL);
567568
index_file_fd = open(tmp_index_file_path, O_RDONLY);
569+
assert(index_file_fd > 0);
568570
}
569571

570-
assert(index_file_fd > 0);
571-
572572
if(!buildstate->external) {
573573
num_added_vectors = usearch_size(buildstate->usearch_index, &error);
574574
}
@@ -598,10 +598,9 @@ static void BuildIndex(Relation heap, Relation index, IndexInfo *indexInfo, ldb_
598598
munmap_ret = munmap(result_buf, index_file_stat.st_size);
599599
assert(munmap_ret == 0);
600600
LDB_UNUSED(munmap_ret);
601+
close(index_file_fd);
601602
}
602603

603-
close(index_file_fd);
604-
605604
if(buildstate->external) {
606605
buildstate->external_socket->close(buildstate->external_socket);
607606
}

0 commit comments

Comments
 (0)