3d8cc972aeac2f853c867a4b4bbbc1b78ae85c7c kent Fri Sep 5 17:04:21 2014 -0700 Adding new pipelineClose() function that combines pipelineWait and pipelineFree and applying it where it makes sense, in some cases fixing non-symptomatic bugs from missing pipelineWaits diff --git src/hg/hgc/hgdpClick.c src/hg/hgc/hgdpClick.c index 940453c..7c1fe18 100644 --- src/hg/hgc/hgdpClick.c +++ src/hg/hgc/hgdpClick.c @@ -184,32 +184,31 @@ {"", "", AM_REGION, AM_PROJ, PSXY_PIX, PSXY_CONT_PLOT, PSXY_CONT_PS, PSXY_WEDGE, "-Gblue", NULL}; static char *psxyBlueAmCmd[] = {"", "", AM_REGION, AM_PROJ, PSXY_PIX, PSXY_CONT_PLOT, PSXY_CIRCLE, "-Gblue", NULL}; static void runCommandAppend(char *cmd[], char *program, char *inFile, char *outFile) /* Use the pipeline module to run a single command pipelineWrite|pipelineAppend. */ { char **cmds[2]; cmds[0] = cmd; cmds[1] = NULL; cmd[0] = program; cmd[1] = inFile; struct pipeline *pl = pipelineOpen(cmds, pipelineWrite|pipelineAppend, outFile, NULL); -pipelineWait(pl); -pipelineFree(&pl); +pipelineClose(&pl); } static void removeDir(char *dirName) /* Remove all files in a directory and the directory itself. */ // NOTE: If this is ever to be libified, beef it up: // 1. Add recursion to subdirs (maybe enabled by a new boolean arg) // 2. Make sure dirName exists // 3. Make sure current dir is not dirName or a subdir of dirName { struct slName *file; struct dyString *dy = dyStringNew(0); for (file = listDir(dirName, "*"); file != NULL; file = file->next) { dyStringClear(dy); dyStringPrintf(dy, "%s/%s", dirName, file->name); @@ -281,42 +280,40 @@ runCommandAppend(psxyOrangeAeaCmd, psxy, pieFile, epsFile); runCommandAppend(psxyPieAeaCmd, psxy, pieFile, epsFile); runCommandAppend(psxyBlueAeaCmd, psxy, circleFile, epsFile); runCommandAppend(psxyOrangeAmCmd, psxy, pieFile, epsFile); runCommandAppend(psxyPieAmCmd, psxy, pieFile, epsFile); runCommandAppend(psxyBlueAmCmd, psxy, circleFile, epsFile); // Make PDF and PNG: struct pipeline *pl; char pdfFile[FILENAME_LEN], pngFile[FILENAME_LEN]; safef(pdfFile, sizeof(pdfFile), "%s.pdf", rootName); safef(pngFile, sizeof(pngFile), "%s.png", rootName); char *ps2pdfCmd[] = {"ps2pdf", epsFile, pdfFile, NULL}; char **cmdsPdf[] = {ps2pdfCmd, NULL}; pl = pipelineOpen(cmdsPdf, pipelineWrite, "/dev/null", NULL); -pipelineWait(pl); -pipelineFree(&pl); +pipelineClose(&pl); char *ps2raster = cfgOption("hgc.ps2rasterPath"); char *ghostscript = cfgOption("hgc.ghostscriptPath"); char gsOpt[PATH_LEN]; safef(gsOpt, sizeof(gsOpt), "-G%s", ghostscript); char *ps2RasterPngCmd[] = {ps2raster, gsOpt, "-P", "-A", "-Tg", "-E150", epsFile, NULL}; char **cmdsPng[] = {ps2RasterPngCmd, NULL}; pl = pipelineOpen(cmdsPng, pipelineRead, "/dev/null", NULL); -pipelineWait(pl); -pipelineFree(&pl); +pipelineClose(&pl); // Back to our usual working directory and $HOME: if (realHome == NULL) unsetenv("HOME"); else setenv("HOME", realHome, TRUE); mustChdir(cwd); // Move the result files into place: char tmpPath[PATH_LEN]; safef(tmpPath, sizeof(tmpPath), "%s/%s", dirTn.forCgi, epsFile); mustRename(tmpPath, finalEpsFile); safef(tmpPath, sizeof(tmpPath), "%s/%s", dirTn.forCgi, pdfFile); mustRename(tmpPath, finalPdfFile); safef(tmpPath, sizeof(tmpPath), "%s/%s", dirTn.forCgi, pngFile);