- Timestamp:
- Apr 19, 2013, 3:39:39 PM (13 years ago)
- Location:
- branches/eam_branches/ipp-20130307/ippTools/src
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
pstamptool.c (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20130307/ippTools/src
- Property svn:mergeinfo changed
/trunk/ippTools/src merged: 35357-35358,35365,35397
- Property svn:mergeinfo changed
-
branches/eam_branches/ipp-20130307/ippTools/src/pstamptool.c
r35350 r35412 49 49 static bool revertjobMode(pxConfig *config); 50 50 51 # if (1)52 // these are unused functions -- since they are 'static', this raises an warning53 // XXX: They actually are used54 51 static bool addprojectMode(pxConfig *config); 55 52 static bool projectMode(pxConfig *config); … … 63 60 static bool listfileMode(pxConfig *config); 64 61 static bool deletefileMode(pxConfig *config); 65 # endif66 62 67 63 # define MODECASE(caseName, func) \ … … 103 99 MODECASE(PSTAMPTOOL_MODE_STOPDEPENDENTJOB, stopdependentjobMode); 104 100 MODECASE(PSTAMPTOOL_MODE_REVERTJOB, revertjobMode); 105 # if (1)106 101 MODECASE(PSTAMPTOOL_MODE_ADDPROJECT, addprojectMode); 107 102 MODECASE(PSTAMPTOOL_MODE_MODPROJECT, modprojectMode); … … 115 110 MODECASE(PSTAMPTOOL_MODE_LISTFILE, listfileMode); 116 111 MODECASE(PSTAMPTOOL_MODE_DELETEFILE, deletefileMode); 117 # endif 112 118 113 default: 119 114 psAbort("invalid option (this should not happen)"); … … 624 619 if (outdir) { 625 620 psStringAppend(&query, ", outdir = '%s'", outdir); 621 } 622 if (username) { 623 psStringAppend(&query, ", username = '%s'", username); 626 624 } 627 625 if (clearfault) { … … 1236 1234 PXOPT_LOOKUP_BOOL(need_magic, config->args, "-need_magic", false); 1237 1235 PXOPT_LOOKUP_BOOL(no_create, config->args, "-no_create", false); 1236 PXOPT_LOOKUP_BOOL(hold, config->args, "-hold", false); 1238 1237 1239 1238 psMetadata *where = psMetadataAlloc(); … … 1243 1242 PXOPT_COPY_STR(config->args, where, "-component", "component", "=="); 1244 1243 1245 // start a transaction e raly so it will contain any row level locks1244 // start a transaction early so it will contain any row level locks 1246 1245 if (!psDBTransaction(config->dbh)) { 1247 1246 psError(PS_ERR_UNKNOWN, false, "database error"); … … 1267 1266 psError(PS_ERR_UNKNOWN, false, "database error"); 1268 1267 psFree(query); 1268 if (!psDBRollback(config->dbh)) { 1269 psError(PS_ERR_UNKNOWN, false, "database error"); 1270 } 1269 1271 return false; 1270 1272 } … … 1274 1276 if (!output) { 1275 1277 psError(PS_ERR_UNKNOWN, false, "database error"); 1278 if (!psDBRollback(config->dbh)) { 1279 psError(PS_ERR_UNKNOWN, false, "database error"); 1280 } 1276 1281 return false; 1277 1282 } … … 1282 1287 psError(PS_ERR_UNKNOWN, false, "database error"); 1283 1288 psFree(output); 1289 if (!psDBRollback(config->dbh)) { 1290 psError(PS_ERR_UNKNOWN, false, "database error"); 1291 } 1284 1292 return false; 1285 1293 } … … 1287 1295 if (fault > 0) { 1288 1296 fprintf(stderr, "existing dependent has fault %d\n", fault); 1297 if (!psDBRollback(config->dbh)) { 1298 psError(PS_ERR_UNKNOWN, false, "database error"); 1299 } 1300 // return the fault to the client. This is used by the postage stamp parser 1289 1301 exit (fault); 1290 1302 } 1303 bool commit = false; 1304 // Check the state of the exisiting dependent. By query it is either 1305 // new or hold 1306 psString state = psMetadataLookupStr(NULL, dep, "state"); 1307 if (!hold && !strcmp(state, "hold")) { 1308 // There is a dependent for this component but it's state is hold. 1309 // This client needs one that will run. 1310 // Update the state 1311 psString updateQuery = NULL; 1312 psStringAppend(&updateQuery, "UPDATE pstampDependent SET state = 'new' " 1313 "\nWHERE stage = '%s' AND imagedb = '%s' AND stage_id = %"PRId64 " AND component = '%s'", 1314 stage, imagedb, stage_id, component); 1315 1316 if (!p_psDBRunQuery(config->dbh, updateQuery)) { 1317 psError(PS_ERR_UNKNOWN, false, "database error"); 1318 psFree(updateQuery); 1319 if (!psDBRollback(config->dbh)) { 1320 psError(PS_ERR_UNKNOWN, false, "database error"); 1321 } 1322 return false; 1323 } 1324 // set flag to commit this change 1325 commit = true; 1326 psFree(updateQuery); 1327 } 1328 // print the dep_id for the user 1291 1329 printf("%" PRId64 "\n", dep_id); 1292 1330 psFree(output); 1293 if (!psDBRollback(config->dbh)) { 1331 // now either commit the change or rollback the transaction which releases the lock 1332 if (commit) { 1333 if (!psDBCommit(config->dbh)) { 1334 // rollback 1335 if (!psDBRollback(config->dbh)) { 1336 psError(PS_ERR_UNKNOWN, false, "database error"); 1337 } 1294 1338 psError(PS_ERR_UNKNOWN, false, "database error"); 1339 return false; 1340 } 1341 } else if (!psDBRollback(config->dbh)) { 1342 psError(PS_ERR_UNKNOWN, false, "database error"); 1343 return false; 1295 1344 } 1296 1345 return true; … … 1310 1359 config->dbh, 1311 1360 0, // dep_id 1312 "new", // state1361 hold ? "hold" : "new", // state 1313 1362 stage, 1314 1363 stage_id,
Note:
See TracChangeset
for help on using the changeset viewer.
