IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 24, 2010, 2:09:10 PM (16 years ago)
Author:
Paul Price
Message:

Use checkPath() on Nebulous files also, to allow NFS system time to show the file existing.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/config/pmConfig.c

    r26636 r27060  
    4242#define DEFAULT_LOG STDERR_FILENO       // Default file descriptor for log messages
    4343#define DEFAULT_TRACE STDERR_FILENO     // Default file descriptor for trace messages
     44
     45#define CHECK_FILE_RETRY 5              // Number of retries when checking a file
     46#define CHECK_FILE_WAIT 250000          // Wait between retries (usec) when checking a file
    4447
    4548static bool readCameraConfig = true;    // Read the camera config on startup (with pmConfigRead)?
     
    552555            psString resolved = pmConfigConvertFilename(logDest, config, true, false); // Resolved filename
    553556            if (!resolved || strlen(resolved) == 0) {
    554                 psWarning("Unable to resolve log destination: %s --- ignored", logDest);
    555             } else {
    556                 pmConfigRunFilenameAddWrite(config, "LOG", logDest);
    557                 config->logFD = psMessageDestination(resolved);
    558             }
     557                psError(psErrorCodeLast(), false, "Unable to resolve log destination: %s", logDest);
     558                psFree(logDest);
     559                return NULL;
     560            }
     561            pmConfigRunFilenameAddWrite(config, "LOG", logDest);
     562            config->logFD = psMessageDestination(resolved);
    559563            psFree(resolved);
    560564            psFree(logDest);
     
    611615            psString resolved = pmConfigConvertFilename(traceDest, config, true, false); // Resolved filename
    612616            if (!resolved || strlen(resolved) == 0) {
    613                 psWarning("Unable to resolve trace destination: %s --- ignored", traceDest);
    614             } else {
    615                 pmConfigRunFilenameAddWrite(config, "TRACE", traceDest);
    616                 config->traceFD = psMessageDestination(resolved);
    617             }
     617                psError(psErrorCodeLast(), false, "Unable to resolve trace destination: %s", traceDest);
     618                psFree(traceDest);
     619                return NULL;
     620            }
     621            pmConfigRunFilenameAddWrite(config, "TRACE", traceDest);
     622            config->traceFD = psMessageDestination(resolved);
    618623            psFree(resolved);
    619624            psFree(traceDest);
     
    15911596
    15921597        char *point = newName + strlen("file:");
    1593         while (*point == '/')
     1598        while (*point == '/') {
    15941599            point ++;
     1600        }
    15951601        char *tmpName = NULL;
    15961602        psStringAppend (&tmpName, "/%s", point);
     
    16001606        if (!checkPath(newName, create, trunc)) {
    16011607            // let checkPath()'s psError() call float up
    1602             psError(PS_ERR_UNKNOWN, false, "error from checkPath for file:// (%s)", newName);
     1608            psError(psErrorCodeLast(), false, "error from checkPath for file:// (%s)", newName);
    16031609            psFree (newName);
    16041610            return NULL;
     
    17121718        nebServerFree(server);
    17131719
    1714         if (trunc) {
    1715             if(truncate(path, 0) != 0) {
    1716                 psError(PS_ERR_IO, true, "Failed to truncate Nebulous file %s (real name %s)\n",
    1717                         filename, path);
    1718                 return NULL;
    1719             }
     1720        // Check to ensure it's there.  Never create, because Nebulous has done that for us.
     1721        if (!checkPath(path, false, trunc)) {
     1722            psError(psErrorCodeLast(), false, "Cannot find file %s", path);
     1723            psFree(path);
     1724            return NULL;
    17201725        }
    17211726
     
    18021807
    18031808    // re-try access up to 5 times (1.25sec) to reduce NFS lurches
    1804     for (int i = 0; i < 5; i++) {
     1809    for (int i = 0; i < CHECK_FILE_RETRY; i++) {
    18051810        if (access(filename, R_OK) == 0) {
    18061811            // file already exists
     
    18271832            return true;
    18281833        }
    1829         usleep (250000);
     1834        usleep(CHECK_FILE_WAIT);
    18301835    }
    18311836
Note: See TracChangeset for help on using the changeset viewer.