diff --git a/src/core/lib/gprpp/load_file.cc b/src/core/lib/gprpp/load_file.cc index e03ee728c06..dc870aef218 100644 --- a/src/core/lib/gprpp/load_file.cc +++ b/src/core/lib/gprpp/load_file.cc @@ -32,6 +32,9 @@ namespace grpc_core { // Loads the content of a file into a slice. add_null_terminator will add a NULL // terminator if true. +// This API is NOT thread-safe and requires proper synchronization when used by +// multiple threads, especially when they can happen to be reading from the same +// file. absl::StatusOr LoadFile(const std::string& filename, bool add_null_terminator) { unsigned char* contents = nullptr; @@ -61,7 +64,6 @@ absl::StatusOr LoadFile(const std::string& filename, bytes_read = fread(contents, 1, contents_size, file); if (bytes_read < contents_size) { gpr_free(contents); - GPR_ASSERT(ferror(file)); error = absl::InternalError( absl::StrCat("Failed to load file: ", filename, " due to error(fread): ", strerror(errno)));