aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar vjpai <vpai@google.com>2015-09-24 16:59:07 -0700
committerGravatar vjpai <vpai@google.com>2015-09-24 16:59:07 -0700
commit7e0289e1c2faf3070d85860aec0369340d0ced33 (patch)
treeae126c87db068668e73fc6d452ee9436178c4ea7
parent87cec156657c004779fbaf65902f5d8213001796 (diff)
Annotate blocking file operations
-rw-r--r--src/core/support/file.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/core/support/file.c b/src/core/support/file.c
index c1361d8a9e..25a566905e 100644
--- a/src/core/support/file.c
+++ b/src/core/support/file.c
@@ -40,6 +40,7 @@
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
+#include "src/core/iomgr/block_annotate.h"
#include "src/core/support/string.h"
gpr_slice gpr_load_file(const char *filename, int add_null_terminator,
@@ -48,9 +49,11 @@ gpr_slice gpr_load_file(const char *filename, int add_null_terminator,
size_t contents_size = 0;
char *error_msg = NULL;
gpr_slice result = gpr_empty_slice();
- FILE *file = fopen(filename, "rb");
+ FILE *file;
size_t bytes_read = 0;
+ GRPC_IOMGR_START_BLOCKING_REGION;
+ file = fopen(filename, "rb");
if (file == NULL) {
gpr_asprintf(&error_msg, "Could not open file %s (error = %s).", filename,
strerror(errno));
@@ -83,5 +86,6 @@ end:
if (success != NULL) *success = 0;
}
if (file != NULL) fclose(file);
+ GRPC_IOMGR_END_BLOCKING_REGION;
return result;
}