From: Michael Tremer Date: Sun, 27 Oct 2024 08:59:47 +0000 (+0000) Subject: transaction: Avoid using a label to retry solving X-Git-Tag: 0.9.30~796 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=93fe30ce247b4b124ba7db9187341d5cf3279a25;p=pakfire.git transaction: Avoid using a label to retry solving Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/transaction.c b/src/libpakfire/transaction.c index c28b3671b..fe2d3ffb3 100644 --- a/src/libpakfire/transaction.c +++ b/src/libpakfire/transaction.c @@ -574,73 +574,75 @@ PAKFIRE_EXPORT int pakfire_transaction_solve(struct pakfire_transaction* transac if (selection) DEBUG(transaction->ctx, "Solving: %s\n", selection); -RETRY: - // Save time when we starting solving - solving_start = clock(); + for (;;) { + // Save time when we starting solving + solving_start = clock(); - // Solve the request and get the number of problems - r = solver_solve(transaction->solver, &transaction->jobs); + // Solve the request and get the number of problems + r = solver_solve(transaction->solver, &transaction->jobs); - // Save time when we finished solving - solving_end = clock(); + // Save time when we finished solving + solving_end = clock(); - DEBUG(transaction->ctx, "Solved request in %.4fms\n", - (double)(solving_end - solving_start) * 1000 / CLOCKS_PER_SEC); + DEBUG(transaction->ctx, "Solved request in %.4fms\n", + (double)(solving_end - solving_start) * 1000 / CLOCKS_PER_SEC); - switch (r) { - // Solved! - case 0: - // Mark as solved - solved = 1; + switch (r) { + // Solved! + case 0: + // Mark as solved + solved = 1; - // Import the transaction - r = pakfire_transaction_import_transaction(transaction); - if (r) - goto ERROR; + // Import the transaction + r = pakfire_transaction_import_transaction(transaction); + if (r) + goto ERROR; - // Import userinstalled packages - r = pakfire_transaction_import_userinstalled(transaction); - if (r) - goto ERROR; + // Import userinstalled packages + r = pakfire_transaction_import_userinstalled(transaction); + if (r) + goto ERROR; - break; +#ifdef ENABLE_DEBUG + // Print all decisions + solver_printdecisions(transaction->solver); +#endif - // Not Solved - default: + goto SOLVED; + + // Not Solved + default: #ifdef ENABLE_DEBUG - // Print all solutions - solver_printallsolutions(transaction->solver); + // Print all solutions + solver_printallsolutions(transaction->solver); #endif - // Fetch the reason why we could not solve the request - p = pakfire_transaction_get_problem_string(transaction, flags); + // Fetch the reason why we could not solve the request + p = pakfire_transaction_get_problem_string(transaction, flags); - if (p) { - DEBUG(transaction->ctx, - "Could not solve request: %s\n%s\n", selection, p); + if (p) { + DEBUG(transaction->ctx, + "Could not solve request: %s\n%s\n", selection, p); - // Return the problems - if (problems) - *problems = strdup(p); - } + // Return the problems + if (problems) + *problems = strdup(p); + } - // Ask the user to pick a solution - r = pakfire_ctx_pick_solution(transaction->ctx, transaction->pakfire, transaction); - switch (r) { - case 0: - goto RETRY; + // Ask the user to pick a solution + r = pakfire_ctx_pick_solution(transaction->ctx, transaction->pakfire, transaction); + switch (r) { + case 0: + continue; - default: - goto ERROR; - } - break; + default: + goto ERROR; + } + break; + } } -#ifdef ENABLE_DEBUG - if (solved) - solver_printdecisions(transaction->solver); -#endif - +SOLVED: // Return zero if solved, otherwise return non-zero if (solved) r = 0;