Skip to content

Commit

Permalink
handle error;close file
Browse files Browse the repository at this point in the history
  • Loading branch information
kazuho committed Nov 27, 2017
1 parent bcd76de commit ecb8e52
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion t/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,10 @@ static int handle_connection(int fd, ptls_context_t *ctx, const char *server_nam
int inputfd = 0, maxfd = fd + 1;

if (input_file != NULL) {
inputfd = open(input_file, O_RDONLY);
if ((inputfd = open(input_file, O_RDONLY)) == -1) {
fprintf(stderr, "failed to open file:%s:%s\n", input_file, strerror(errno));
exit(1);
}
if (inputfd >= maxfd)
maxfd = inputfd + 1;
}
Expand Down Expand Up @@ -234,6 +237,8 @@ static int handle_connection(int fd, ptls_context_t *ctx, const char *server_nam
Exit:
ptls_buffer_dispose(&wbuf);
ptls_free(tls);
if (input_file != NULL)
close(inputfd);
return 0;
}

Expand Down

0 comments on commit ecb8e52

Please sign in to comment.