Changeset 20480 for trunk/psModules/src/config/pmConfig.c
- Timestamp:
- Oct 30, 2008, 2:43:45 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/config/pmConfig.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/config/pmConfig.c
r20345 r20480 1351 1351 psMetadataItem *rulesItem = NULL; // Item from iteration 1352 1352 while ((rulesItem = psMetadataGetAndIncrement(rulesIter))) { 1353 // this will insert each of the MULTI entries, writing over the previous copies 1354 if (PS_DATA_IS_PRIMITIVE (rulesItem->type) || (rulesItem->type == PS_DATA_STRING)) { 1355 psMetadataItem *newItem = psMetadataItemCopy(rulesItem); // Copy of item 1356 psMetadataAddItem(header, newItem, PS_LIST_TAIL, PS_META_REPLACE); 1357 psFree(newItem); // Drop reference 1358 continue; 1359 } 1360 1361 # if (0) // XXX not needed 1362 // for MULTI entries, supply the first one 1363 if (rulesItem->type == PS_DATA_METADATA_MULTI) { 1364 psMetadataItem *entry = psListGet (rulesItem->data.list, PS_LIST_HEAD); 1365 if (!entry) { 1366 psError(PS_ERR_UNKNOWN, true, "No entries for MULTI RULE item."); 1367 return false; 1368 } 1369 psMetadataItem *newItem = psMetadataItemCopy(entry); // Copy of item 1370 psMetadataAddItem(header, newItem, PS_LIST_TAIL, PS_META_REPLACE); 1371 psFree(newItem); // Drop reference 1372 continue; 1373 } 1374 # endif 1375 1376 psError(PS_ERR_UNKNOWN, false, "Invalid type for RULE %s.", rulesItem->name); 1377 return false; 1353 if (!PS_DATA_IS_PRIMITIVE(rulesItem->type) && rulesItem->type != PS_DATA_STRING) { 1354 psError(PS_ERR_UNKNOWN, false, "Invalid type for RULE %s.", rulesItem->name); 1355 return false; 1356 } 1357 1358 psMetadataItem *hdrItem = psMetadataLookup(header, rulesItem->name); // Item from header 1359 if (hdrItem && psMetadataItemCompare(hdrItem, rulesItem)) { 1360 // It's already there and matches 1361 break; 1362 } 1363 1364 // Look for an operation 1365 psMetadataItemCompareOp op = psMetadataItemCompareOperation(rulesItem); 1366 switch (op) { 1367 case PS_METADATA_ITEM_COMPARE_OP_NONE: 1368 case PS_METADATA_ITEM_COMPARE_OP_EQ: 1369 case PS_METADATA_ITEM_COMPARE_OP_LE: 1370 case PS_METADATA_ITEM_COMPARE_OP_GE: { 1371 // A comparison involving equality: add the value 1372 psMetadataItem *newItem = psMetadataItemCopy(rulesItem); // Copy of item 1373 if (op == PS_METADATA_ITEM_COMPARE_OP_LE || op == PS_METADATA_ITEM_COMPARE_OP_GE) { 1374 // Not clear what the value is supposed to be, so add a warning as well 1375 psFree(newItem->comment); 1376 newItem->comment = psStringCopy("MAY BE WRONG: added to match format rule"); 1377 } 1378 psMetadataAddItem(header, newItem, PS_LIST_TAIL, PS_META_REPLACE); 1379 psFree(newItem); // Drop reference 1380 break; 1381 } 1382 case PS_METADATA_ITEM_COMPARE_OP_LT: 1383 case PS_METADATA_ITEM_COMPARE_OP_GT: 1384 case PS_METADATA_ITEM_COMPARE_OP_NE: 1385 // It's not at all obvious what the value should be, so return an error. 1386 psError(PS_ERR_IO, true, 1387 "RULE %s (defined by an OPeration) is not present or not consistent in output header", 1388 rulesItem->name); 1389 return false; 1390 default: 1391 psAbort("Unknown operation: %x", op); 1392 } 1378 1393 } 1379 1394 psFree(rulesIter); … … 1722 1737 // re-try access up to 5 times (1.25sec) to reduce NFS lurches 1723 1738 for (int i = 0; i < 5; i++) { 1724 if (access(filename, R_OK) == 0) {1725 // file already exists1726 if (trunc) {1727 if(truncate(filename, 0) != 0) {1728 psError(PS_ERR_IO, true, "Failed to truncate file, %s\n", filename);1729 return false;1730 }1731 }1732 return true;1733 } 1739 if (access(filename, R_OK) == 0) { 1740 // file already exists 1741 if (trunc) { 1742 if(truncate(filename, 0) != 0) { 1743 psError(PS_ERR_IO, true, "Failed to truncate file, %s\n", filename); 1744 return false; 1745 } 1746 } 1747 return true; 1748 } 1734 1749 1735 1750 // file does not exist … … 1744 1759 return false; 1745 1760 } 1746 return true;1747 } 1748 usleep (250000);1761 return true; 1762 } 1763 usleep (250000); 1749 1764 } 1750 1765
Note:
See TracChangeset
for help on using the changeset viewer.
