Changeset 20260
- Timestamp:
- Oct 18, 2008, 9:04:26 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/config/pmConfig.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/config/pmConfig.c
r20254 r20260 1721 1721 PS_ASSERT_PTR_NON_NULL(filename, false); 1722 1722 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 1732 1736 // file does not exist 1733 1737 if (create) { 1734 1738 int fd = open(filename, O_WRONLY|O_CREAT, 0666); 1735 1739 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); 1737 1741 return false; 1738 1742 } … … 1741 1745 return false; 1742 1746 } 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.
