lttd: 0.75, improve error handling of file open
authorMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Sun, 15 Nov 2009 07:12:14 +0000 (02:12 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Sun, 15 Nov 2009 07:12:14 +0000 (02:12 -0500)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
configure.in
lttd/lttd.c

index 51e8f26d5e26dbb69a0914f034077868414333a3..82cc2c30cd46f079dfe6987f4c0b449ed1cd6628 100644 (file)
@@ -23,7 +23,7 @@
 AC_PREREQ(2.57)
 AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)
 #AC_WITH_LTDL  # not needed ?
-AM_INIT_AUTOMAKE(ltt-control,0.74-12112009)
+AM_INIT_AUTOMAKE(ltt-control,0.75-15112009)
 AM_CONFIG_HEADER(config.h)
 AM_PROG_LIBTOOL
 
index 61d24688f4283170f8cf98cb3ffe0b5075305d7c..b2e7127833141da0f66515918f73af51444398d1 100644 (file)
@@ -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;
                        }
                }
        }
This page took 0.024943 seconds and 4 git commands to generate.