浏览代码

write_bus_affinity_file_content: Do not open the file if there is nothing to write.

This fixes a resource leak : the file use to be always opened, but not always closed.
Cyril Roelandt 13 年之前
父节点
当前提交
f00cc9ea86
共有 1 个文件被更改,包括 2 次插入4 次删除
  1. 2 4
      src/core/perfmodel/perfmodel_bus.c

+ 2 - 4
src/core/perfmodel/perfmodel_bus.c

@@ -662,13 +662,12 @@ static void load_bus_affinity_file_content(void)
 
 static void write_bus_affinity_file_content(void)
 {
-	FILE *f;
-
 	STARPU_ASSERT(was_benchmarked);
 
+#if defined(STARPU_USE_CUDA) || defined(STARPU_USE_OPENCL)
+	FILE *f;
 	char path[256];
 	get_affinity_path(path, 256);
-
 	f = fopen(path, "w+");
 	if (!f)
 	{
@@ -678,7 +677,6 @@ static void write_bus_affinity_file_content(void)
 		STARPU_ABORT();
 	}
 
-#if defined(STARPU_USE_CUDA) || defined(STARPU_USE_OPENCL)
 	unsigned cpu;
         int gpu;