ret = fres_forbex2err(&ev);
goto err_free;
}
+
return 0;
err_free:
forb_sequence_free_buf(&commit_ids, forb_no_destructor);
return ret;
}
+/* Add new contracts to our fcb database for later
+ * reference. Canceled contracts are removed below. */
+int
+fcb_remember_contracts(struct fcb *fcb,
+ struct fcb_contract **fcb_contracts,
+ int num)
+{
+ struct fcb_contract *fc;
+ int i;
+
+ for (i=0; i<num; i++) {
+ fc = fcb_contracts[i];
+
+ if (fc->user_contract) {
+ if (fres_contract_get_num_blocks(fc->requested_contract) > 0) {
+ /* Renegotiation */
+ fres_contract_destroy(fc->user_contract);
+ fc->user_contract = fres_contract_duplicate(fc->requested_contract);
+ /* Note: requested_contract is also
+ * pointed by contracts parameter and
+ * will be freed by FORB. */
+ fc->requested_contract = NULL;
+ }
+ } else {
+ /* Insert new contracts */
+ fcb_contract_insert(fcb, fcb_contracts[i]);
+ fc->user_contract = fres_contract_duplicate(fc->requested_contract);
+ fc->requested_contract = NULL;
+ /* See the note above. */
+ }
+ }
+ return 0;
+}
CORBA_long
negotiate_contracts(fres_contract_broker obj,
int ret = 0;
forb_server_id app;
fres_contract_ptr_seq *schedulable_contracts;
- struct fcb_contract **fcb_contracts, *fc;
+ struct fcb_contract **fcb_contracts;
unsigned i;
int num = contracts->_length;
if (ret)
goto err_cancel_reservation;
- /* Add new contracts to our fcb database for later
- * reference. Canceled contracts are removed below. */
- for (i=0; i<num; i++) {
- fc = fcb_contracts[i];
-
- if (fc->user_contract) {
- if (fres_contract_get_num_blocks(fc->requested_contract) > 0) {
- /* Renegotiation */
- fres_contract_destroy(fc->user_contract);
- fc->user_contract = fres_contract_duplicate(fc->requested_contract);
- /* Note: requested_contract is also
- * pointed by contracts parameter and
- * will be freed by FORB. */
- fc->requested_contract = NULL;
- }
- } else {
- /* Insert new contracts */
- fcb_contract_insert(fcb, fcb_contracts[i]);
- fc->user_contract = fres_contract_duplicate(fc->requested_contract);
- fc->requested_contract = NULL;
- /* See the note above. */
- }
- }
+ fcb_remember_contracts(fcb, fcb_contracts, num);
ret = change_vreses(fcb, schedulable_contracts);
if (ret)
struct res_array res_array;
struct res_key key;
struct resource *resource;
+ fres_contract_ptr_seq *schedulable_contracts;
- ul_logmsg("Negotiating transaction of %d contracts\n", num);
+ ul_logmsg("Negotiating transaction with %d contracts\n", num);
if (transaction_has_spare_capacity(transaction)) {
ret = FRES_ERR_SPARE_CAPACITY_NOT_SUPPORTED;
goto err;
}
}
gsa_cust_for_each(res_array, &res_array, resource) {
- ret = commit_resource(resource);
+ ret = commit_resource(resource, &schedulable_contracts);
if (ret) {
ul_logerr("Commit failed\n");
goto err_cancel_reservation;
}
}
+ fcb_remember_contracts(fcb, fcb_contracts, num);
+ forb_sequence_free(schedulable_contracts, fres_contract_ptr_destroy);
res_array_delete_all(&res_array);
return 0;