[PATCH] blktrace: only do ioctl stop on local trace
authorJens Axboe <axboe@suse.de>
Tue, 21 Feb 2006 12:21:34 +0000 (13:21 +0100)
committerJens Axboe <axboe@suse.de>
Tue, 21 Feb 2006 12:21:34 +0000 (13:21 +0100)
blktrace.c

index c9665a86803d900a87e91b630d6bcc008d1bb542..a87ef0d55c14397b472561777fe63b3fdbbd3918 100644 (file)
@@ -304,6 +304,8 @@ static void handle_sigint(__attribute__((__unused__)) int sig)
         * stop trace so we can reap currently produced data
         */
        for_each_dip(dip, i) {
+               if (dip->fd == -1)
+                       continue;
                if (ioctl(dip->fd, BLKTRACESTOP) < 0)
                        perror("BLKTRACESTOP");
        }
@@ -1305,8 +1307,10 @@ static struct device_information *net_get_dip(char *buts_name,
 
        device_information = realloc(device_information, (ndevs + 1) * sizeof(*dip));
        dip = &device_information[ndevs];
+       memset(dip, 0, sizeof(*dip));
+       dip->fd = -1;
        strcpy(dip->buts_name, buts_name);
-       strcpy(dip->path, buts_name);
+       dip->path = strdup(buts_name);
        ndevs++;
        dip->threads = malloc(ncpus * sizeof(struct thread_information));
        memset(dip->threads, 0, ncpus * sizeof(struct thread_information));
@@ -1488,6 +1492,7 @@ repeat:
                        fclose(tip->ofile);
 
                free(dip->threads);
+               free(dip->path);
        }
 
        free(device_information);