IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 26117


Ignore:
Timestamp:
Nov 12, 2009, 4:38:34 PM (16 years ago)
Author:
Paul Price
Message:

Fix SEGV from doing cleanup in wrong place. Moved deletion of temporary files to ppStackFinish().

Location:
trunk/ppStack/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppStack/src/ppStackCleanup.c

    r26076 r26117  
    44
    55#include <stdio.h>
    6 #include <unistd.h>
    76#include <pslib.h>
    87#include <psmodules.h>
     
    2221    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // ppStack recipe
    2322    psAssert(recipe, "We've thrown an error on this before.");
    24 
    25     bool mdok;                          // Status of MD lookup
    26     bool tempDelete = psMetadataLookupBool(&mdok, recipe, "TEMP.DELETE"); // Delete temporary files?
    2723
    2824#if 0
     
    7268            }
    7369        }
    74 
    75         if (tempDelete) {
    76             psString imageResolved = pmConfigConvertFilename(options->convImages->data[i],
    77                                                              config, false, false);
    78             psString maskResolved = pmConfigConvertFilename(options->convMasks->data[i],
    79                                                             config, false, false);
    80             psString varianceResolved = pmConfigConvertFilename(options->convVariances->data[i],
    81                                                                 config, false, false);
    82             if (unlink(imageResolved) == -1 || unlink(maskResolved) == -1 ||
    83                 unlink(varianceResolved) == -1) {
    84                 psWarning("Unable to delete temporary files for image %d", i);
    85             }
    86             psFree(imageResolved);
    87             psFree(maskResolved);
    88             psFree(varianceResolved);
    89         }
    9070    }
    9171
  • trunk/ppStack/src/ppStackFinish.c

    r25847 r26117  
    44
    55#include <stdio.h>
     6#include <unistd.h>
    67#include <pslib.h>
    78#include <psmodules.h>
     
    2021    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // ppStack recipe
    2122    psAssert(recipe, "We've thrown an error on this before.");
     23
     24    bool mdok;                          // Status of MD lookup
     25    bool tempDelete = psMetadataLookupBool(&mdok, recipe, "TEMP.DELETE"); // Delete temporary files?
     26
     27    // Delete temporary images
     28    if (tempDelete && options->convolve) {
     29        for (int i = 0; i < options->num; i++) {
     30            if (options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {
     31                continue;
     32            }
     33
     34            psString imageResolved = pmConfigConvertFilename(options->convImages->data[i],
     35                                                             config, false, false);
     36            psString maskResolved = pmConfigConvertFilename(options->convMasks->data[i],
     37                                                            config, false, false);
     38            psString varianceResolved = pmConfigConvertFilename(options->convVariances->data[i],
     39                                                                config, false, false);
     40            if (unlink(imageResolved) == -1 || unlink(maskResolved) == -1 ||
     41                unlink(varianceResolved) == -1) {
     42                psWarning("Unable to delete temporary files for image %d", i);
     43            }
     44            psFree(imageResolved);
     45            psFree(maskResolved);
     46            psFree(varianceResolved);
     47        }
     48    }
     49
    2250
    2351    // Statistics on output
     
    4472    }
    4573
    46 
    4774    // Write out summary statistics
    4875    if (options->stats) {
     
    6188    }
    6289
    63 
    6490    // Dump configuration
    65     bool mdok;                          // Status of MD lookup
    6691    psString dump = psMetadataLookupStr(&mdok, config->arguments, "DUMP_CONFIG"); // File for config
    6792    if (dump) {
  • trunk/ppStack/src/ppStackLoop.c

    r26106 r26117  
    106106    ppStackMemDump("final");
    107107
     108    // Clean up
     109    psTrace("ppStack", 2, "Cleaning up after combination....\n");
     110    if (!ppStackCleanup(stack, options, config)) {
     111        psError(PS_ERR_UNKNOWN, false, "Unable to clean up.");
     112        psFree(stack);
     113        psFree(options);
     114        return false;
     115    }
     116    psLogMsg("ppStack", PS_LOG_INFO, "Stage 6: Cleanup, WCS & JPEGS: %f sec", psTimerClear("PPSTACK_STEPS"));
     117    ppStackMemDump("cleanup");
     118
    108119    psFree(stack);
    109120
     
    125136            return false;
    126137        }
    127         psLogMsg("ppStack", PS_LOG_INFO, "Stage 6: Unconvolved Stack: %f sec", psTimerClear("PPSTACK_STEPS"));
     138        psLogMsg("ppStack", PS_LOG_INFO, "Stage 7: Unconvolved Stack: %f sec", psTimerClear("PPSTACK_STEPS"));
    128139        ppStackMemDump("unconv");
    129140
     
    132143    psFree(options->cells); options->cells = NULL;
    133144#endif
    134 
    135     // Clean up
    136     psTrace("ppStack", 2, "Cleaning up after combination....\n");
    137     if (!ppStackCleanup(stack, options, config)) {
    138         psError(PS_ERR_UNKNOWN, false, "Unable to clean up.");
    139         psFree(stack);
    140         psFree(options);
    141         return false;
    142     }
    143     psLogMsg("ppStack", PS_LOG_INFO, "Stage 7: Cleanup, WCS & JPEGS: %f sec", psTimerClear("PPSTACK_STEPS"));
    144     ppStackMemDump("cleanup");
    145145
    146146    // Photometry
Note: See TracChangeset for help on using the changeset viewer.