X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=lttd%2Flttd.c;h=b2e7127833141da0f66515918f73af51444398d1;hb=1ee8f63e50275f083b5ab1836658e50a49c1e330;hp=f21c411eb8940de479fb62980917c6880fae7e99;hpb=5e1fd42a8d1bbbe1e1283e4c652994ff738dd6a7;p=ltt-control.git diff --git a/lttd/lttd.c b/lttd/lttd.c index f21c411..b2e7127 100644 --- a/lttd/lttd.c +++ b/lttd/lttd.c @@ -320,15 +320,26 @@ int open_buffer_file(char *filename, char *path_channel, char *path_trace, S_IRWXU|S_IRWXG|S_IRWXO); if(fd_pairs->pair[fd_pairs->num_pairs-1].trace == -1) { perror(path_trace); + open_ret = -1; + close(fd_pairs->pair[fd_pairs->num_pairs-1].channel); + fd_pairs->num_pairs--; + goto end; } ret = lseek(fd_pairs->pair[fd_pairs->num_pairs-1].trace, 0, SEEK_END); if (ret < 0) { perror(path_trace); + open_ret = -1; + close(fd_pairs->pair[fd_pairs->num_pairs-1].channel); + close(fd_pairs->pair[fd_pairs->num_pairs-1].trace); + fd_pairs->num_pairs--; + goto end; } } else { printf("File %s exists, cannot open. Try append mode.\n", path_trace); open_ret = -1; + close(fd_pairs->pair[fd_pairs->num_pairs-1].channel); + fd_pairs->num_pairs--; goto end; } } else { @@ -338,6 +349,10 @@ int open_buffer_file(char *filename, char *path_channel, char *path_trace, S_IRWXU|S_IRWXG|S_IRWXO); if(fd_pairs->pair[fd_pairs->num_pairs-1].trace == -1) { perror(path_trace); + open_ret = -1; + close(fd_pairs->pair[fd_pairs->num_pairs-1].channel); + fd_pairs->num_pairs--; + goto end; } } } @@ -472,14 +487,14 @@ int read_subbuffer(struct fd_pair *pair) printf_verbose("splice chan to pipe offset %lu\n", (unsigned long)offset); ret = splice(pair->channel, &offset, thread_pipe[1], NULL, - len, SPLICE_F_MOVE); + len, SPLICE_F_MOVE | SPLICE_F_MORE); printf_verbose("splice chan to pipe ret %ld\n", ret); if (ret < 0) { perror("Error in relay splice"); goto write_error; } ret = splice(thread_pipe[0], NULL, pair->trace, NULL, - ret, SPLICE_F_MOVE); + ret, SPLICE_F_MOVE | SPLICE_F_MORE); printf_verbose("splice pipe to file %ld\n", ret); if (ret < 0) { perror("Error in file splice");