IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 18, 2008, 9:04:26 AM (18 years ago)
Author:
eugene
Message:

adding 5 re-tries to checkPath

File:
1 edited

Legend:

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

    r20254 r20260  
    17211721    PS_ASSERT_PTR_NON_NULL(filename, false);
    17221722
    1723     if (access(filename, R_OK) == 0) {
    1724         // file already exists
    1725         if (trunc) {
    1726             if(truncate(filename, 0) != 0) {
    1727                 psError(PS_ERR_IO, true, "Failed to truncate file, %s\n", filename);
    1728                 return false;
    1729             }
    1730         }
    1731     } else {
     1723    // re-try access up to 5 times (1.25sec) to reduce NFS lurches
     1724    for (int i = 0; i < 5; i++) {
     1725        if (access(filename, R_OK) == 0) {
     1726            // file already exists
     1727            if (trunc) {
     1728                if(truncate(filename, 0) != 0) {
     1729                    psError(PS_ERR_IO, true, "Failed to truncate file, %s\n", filename);
     1730                    return false;
     1731                }
     1732            }
     1733            return true;
     1734        }
     1735
    17321736        // file does not exist
    17331737        if (create) {
    17341738            int fd = open(filename, O_WRONLY|O_CREAT, 0666);
    17351739            if (fd == 0) {
    1736                 psError(PS_ERR_IO, true, "Failed to close file, %s\n", filename);
     1740                psError(PS_ERR_IO, true, "Failed to open & create file, %s\n", filename);
    17371741                return false;
    17381742            }
     
    17411745                return false;
    17421746            }
    1743         } else {
    1744             // if the file does not exist and create isn't set, then we
    1745             // should puke
    1746             psError(PS_ERR_IO, true, "Unable to access file %s", filename);
    1747             return false;
    1748         }
    1749     }
    1750 
    1751     return true;
    1752 }
    1753 
     1747            return true;
     1748        }
     1749        usleep (250000);
     1750    }
     1751
     1752    // We've tried 5 times to access the file; give up and report a problem.  If the file does
     1753    // not exist and create isn't set, then we should puke
     1754    psError(PS_ERR_IO, true, "Unable to access file %s", filename);
     1755    return false;
     1756}
Note: See TracChangeset for help on using the changeset viewer.