IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 25, 2010, 10:58:13 AM (16 years ago)
Author:
Paul Price
Message:

Ensure files are closed when exiting with an error. Moved target PSF to its own file so that it can be closed independently of the images (they share data_exists, which need to have multiple states if they're on the same file).

File:
1 edited

Legend:

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

    r27004 r27075  
    5555
    5656
    57      // Common code for the death.
    58 die:
    59     psTrace("ppStack", 1, "Finished at %f sec\n", psTimerMark(TIMER_NAME));
    60     psTimerStop();
     57 die:
     58    // Common code for the death.
     59    {
     60        psExit exitValue = PS_EXIT_SUCCESS;        // Exit value for program
     61        psErrorCode errorCode = psErrorCodeLast(); // Error code
     62        if (errorCode != PS_ERR_NONE) {
     63            psErrorStackPrint(stderr, "Unable to perform stack.");
     64            switch (errorCode) {
     65              case PPSTACK_ERR_UNKNOWN:
     66              case PS_ERR_UNKNOWN:
     67                exitValue = PS_EXIT_UNKNOWN_ERROR;
     68                break;
     69              case PS_ERR_IO:
     70              case PS_ERR_DB_CLIENT:
     71              case PS_ERR_DB_SERVER:
     72              case PS_ERR_BAD_FITS:
     73              case PS_ERR_OS_CALL_FAILED:
     74              case PPSTACK_ERR_IO:
     75                exitValue = PS_EXIT_SYS_ERROR;
     76                break;
     77              case PS_ERR_BAD_PARAMETER_VALUE:
     78              case PS_ERR_BAD_PARAMETER_TYPE:
     79              case PS_ERR_BAD_PARAMETER_NULL:
     80              case PS_ERR_BAD_PARAMETER_SIZE:
     81              case PPSTACK_ERR_ARGUMENTS:
     82              case PPSTACK_ERR_CONFIG:
     83                exitValue = PS_EXIT_CONFIG_ERROR;
     84                break;
     85              case PPSTACK_ERR_PSF:
     86              case PPSTACK_ERR_REJECTED:
     87              case PPSTACK_ERR_DATA:
     88                exitValue = PS_EXIT_DATA_ERROR;
     89                break;
     90              case PS_ERR_UNEXPECTED_NULL:
     91              case PS_ERR_PROGRAMMING:
     92              case PPSTACK_ERR_NOT_IMPLEMENTED:
     93              case PPSTACK_ERR_PROG:
     94              default:
     95                // It's a programming error if we're not dealing with the error correctly
     96                exitValue = PS_EXIT_PROG_ERROR;
     97                break;
     98            }
     99        }
    61100
    62     psFree(config);
    63     pmModelClassCleanup();
    64     pmConfigDone();
    65     psLibFinalize();
    66     pmVisualClose();
     101        // Ensure everything closes
     102        ppStackFileActivation(config, PPSTACK_FILES_PREPARE, true);
     103        ppStackFileActivation(config, PPSTACK_FILES_CONVOLVE, true);
     104        ppStackFileActivation(config, PPSTACK_FILES_COMBINE, true);
     105        ppStackFileActivation(config, PPSTACK_FILES_PHOT, true);
     106        if (!ppStackFilesIterateUp(config)) {
     107            psErrorStackPrint(stderr, "Unable to close files.");
     108        }
    67109
    68     psExit exitValue = PS_EXIT_SUCCESS;        // Exit value for program
    69     psErrorCode errorCode = psErrorCodeLast(); // Error code
    70     if (errorCode != PS_ERR_NONE) {
    71         psErrorStackPrint(stderr, "Unable to perform stack.");
    72         switch (errorCode) {
    73           case PPSTACK_ERR_UNKNOWN:
    74           case PS_ERR_UNKNOWN:
    75             exitValue = PS_EXIT_UNKNOWN_ERROR;
    76             break;
    77           case PS_ERR_IO:
    78           case PS_ERR_DB_CLIENT:
    79           case PS_ERR_DB_SERVER:
    80           case PS_ERR_BAD_FITS:
    81           case PS_ERR_OS_CALL_FAILED:
    82           case PPSTACK_ERR_IO:
    83             exitValue = PS_EXIT_SYS_ERROR;
    84             break;
    85           case PS_ERR_BAD_PARAMETER_VALUE:
    86           case PS_ERR_BAD_PARAMETER_TYPE:
    87           case PS_ERR_BAD_PARAMETER_NULL:
    88           case PS_ERR_BAD_PARAMETER_SIZE:
    89           case PPSTACK_ERR_ARGUMENTS:
    90           case PPSTACK_ERR_CONFIG:
    91             exitValue = PS_EXIT_CONFIG_ERROR;
    92             break;
    93           case PPSTACK_ERR_PSF:
    94           case PPSTACK_ERR_REJECTED:
    95           case PPSTACK_ERR_DATA:
    96             exitValue = PS_EXIT_DATA_ERROR;
    97             break;
    98           case PS_ERR_UNEXPECTED_NULL:
    99           case PS_ERR_PROGRAMMING:
    100           case PPSTACK_ERR_NOT_IMPLEMENTED:
    101           case PPSTACK_ERR_PROG:
    102           default:
    103             // It's a programming error if we're not dealing with the error correctly
    104             exitValue = PS_EXIT_PROG_ERROR;
    105             break;
    106         }
     110        psTrace("ppStack", 1, "Finished at %f sec\n", psTimerMark(TIMER_NAME));
     111        psTimerStop();
     112
     113        psFree(config);
     114        pmModelClassCleanup();
     115        pmConfigDone();
     116        psLibFinalize();
     117        pmVisualClose();
     118
     119        exit(exitValue);
    107120    }
    108 
    109     exit(exitValue);
    110121}
    111122
Note: See TracChangeset for help on using the changeset viewer.