Changeset 35365
- Timestamp:
- Apr 4, 2013, 3:00:07 PM (13 years ago)
- Location:
- trunk/ippTools
- Files:
-
- 3 edited
-
share/pstamptool_getdependent.sql (modified) (1 diff)
-
src/pstamptool.c (modified) (6 diffs)
-
src/pstamptoolConfig.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/share/pstamptool_getdependent.sql
r28145 r35365 1 1 SELECT DISTINCT pstampDependent.* 2 2 FROM pstampDependent 3 WHERE pstampDependent.state = 'new'3 WHERE (pstampDependent.state = 'new' OR pstampDependent.state = 'hold') -
trunk/ippTools/src/pstamptool.c
r35357 r35365 1234 1234 PXOPT_LOOKUP_BOOL(need_magic, config->args, "-need_magic", false); 1235 1235 PXOPT_LOOKUP_BOOL(no_create, config->args, "-no_create", false); 1236 PXOPT_LOOKUP_BOOL(hold, config->args, "-hold", false); 1236 1237 1237 1238 psMetadata *where = psMetadataAlloc(); … … 1265 1266 psError(PS_ERR_UNKNOWN, false, "database error"); 1266 1267 psFree(query); 1268 if (!psDBRollback(config->dbh)) { 1269 psError(PS_ERR_UNKNOWN, false, "database error"); 1270 } 1267 1271 return false; 1268 1272 } … … 1272 1276 if (!output) { 1273 1277 psError(PS_ERR_UNKNOWN, false, "database error"); 1278 if (!psDBRollback(config->dbh)) { 1279 psError(PS_ERR_UNKNOWN, false, "database error"); 1280 } 1274 1281 return false; 1275 1282 } … … 1280 1287 psError(PS_ERR_UNKNOWN, false, "database error"); 1281 1288 psFree(output); 1289 if (!psDBRollback(config->dbh)) { 1290 psError(PS_ERR_UNKNOWN, false, "database error"); 1291 } 1282 1292 return false; 1283 1293 } … … 1285 1295 if (fault > 0) { 1286 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 1287 1301 exit (fault); 1288 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 1289 1329 printf("%" PRId64 "\n", dep_id); 1290 1330 psFree(output); 1291 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 } 1292 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; 1293 1344 } 1294 1345 return true; … … 1308 1359 config->dbh, 1309 1360 0, // dep_id 1310 "new", // state1361 hold ? "hold" : "new", // state 1311 1362 stage, 1312 1363 stage_id, -
trunk/ippTools/src/pstamptoolConfig.c
r35318 r35365 223 223 psMetadataAddBool(getdependentArgs,PS_LIST_TAIL, "-need_magic", 0, "define need_magic", false); 224 224 psMetadataAddStr(getdependentArgs, PS_LIST_TAIL, "-outdir", 0, "define output directory for dependent (required)", NULL); 225 psMetadataAddBool(getdependentArgs,PS_LIST_TAIL, "-hold", 0, "if creating new dependent set it's state to hold", false); 225 226 psMetadataAddBool(getdependentArgs,PS_LIST_TAIL, "-no_create", 0, "if no matching dependent do not create one", false); 226 227
Note:
See TracChangeset
for help on using the changeset viewer.
