From: Jens Axboe Date: Tue, 21 Feb 2006 12:21:34 +0000 (+0100) Subject: [PATCH] blktrace: only do ioctl stop on local trace X-Git-Tag: blktrace-0.99.1~20 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=921b05fed251b6352a07635aa91e7fbad7f5b7f9;p=blktrace.git [PATCH] blktrace: only do ioctl stop on local trace --- diff --git a/blktrace.c b/blktrace.c index c9665a8..a87ef0d 100644 --- a/blktrace.c +++ b/blktrace.c @@ -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);