From 01bf18f5bc3fa9008a19c7c2c20ac1b99cd4fd52 Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Fri, 25 Jun 2010 16:41:17 +0200 Subject: [PATCH] Started implementation of frsh_transaction_alloc_vres() --- fres/cbroker/fcb.c | 15 ++++++++++++++- fres/cbroker/fcb.idl | 2 +- fres/contract/fres_error.c | 1 + fres/contract/fres_error.h | 1 + frsh_api/frsh_transaction.c | 14 ++++++++++++-- frsh_api/tests/trans_nego.c | 3 ++- 6 files changed, 31 insertions(+), 5 deletions(-) diff --git a/fres/cbroker/fcb.c b/fres/cbroker/fcb.c index 40b17eb..bd0f5cb 100644 --- a/fres/cbroker/fcb.c +++ b/fres/cbroker/fcb.c @@ -1309,10 +1309,23 @@ wait_transaction(fres_contract_broker _obj, CORBA_long allocate_transaction_vres(fres_contract_broker _obj, + const CORBA_char * name, const CORBA_long id, CORBA_Environment *ev) { - return FRSH_ERR_NOT_IMPLEMENTED; + struct fcb *fcb = o2fcb(_obj); + struct fcb_transaction *ft; + int ret; + char * const n = (char * const)&name; + + ft = fcb_transaction_find(fcb, &n); + if (!ft) { + ret = FRES_ERR_TRANSACTION_NOT_FOUND; + goto err; + } + ret = 0; +err: + return ret; } diff --git a/fres/cbroker/fcb.idl b/fres/cbroker/fcb.idl index 70eb59a..34cda1a 100644 --- a/fres/cbroker/fcb.idl +++ b/fres/cbroker/fcb.idl @@ -158,7 +158,7 @@ module fres { long negotiate_transaction(in transaction_t transaction); long wait_transaction(in string name, out transaction_t transaction); - long allocate_transaction_vres(in long id); + long allocate_transaction_vres(in string name, in long id); }; }; diff --git a/fres/contract/fres_error.c b/fres/contract/fres_error.c index c66d893..64ec91c 100644 --- a/fres/contract/fres_error.c +++ b/fres/contract/fres_error.c @@ -127,6 +127,7 @@ int fres_strerror (int error, char *message, size_t size) MSG(VRES_ALREADY_ALLOCATED); MSG(VRES_PART_OF_TRANSACTION); MSG(SPARE_CAPACITY_NOT_SUPPORTED); + MSG(TRANSACTION_NOT_FOUND); } if (s == NULL) return FRSH_ERR_BAD_ARGUMENT; diff --git a/fres/contract/fres_error.h b/fres/contract/fres_error.h index 29f1430..690895c 100644 --- a/fres/contract/fres_error.h +++ b/fres/contract/fres_error.h @@ -96,6 +96,7 @@ enum fres_error { FRES_ERR_VRES_ALREADY_ALLOCATED, FRES_ERR_VRES_PART_OF_TRANSACTION, FRES_ERR_SPARE_CAPACITY_NOT_SUPPORTED, + FRES_ERR_TRANSACTION_NOT_FOUND, }; int fres_strerror (int error, char *message, size_t size); diff --git a/frsh_api/frsh_transaction.c b/frsh_api/frsh_transaction.c index da64aea..e1be8ad 100644 --- a/frsh_api/frsh_transaction.c +++ b/frsh_api/frsh_transaction.c @@ -84,6 +84,7 @@ frsh_transaction_negotiate(frsh_transaction_t *trans) { int ret; struct forb_env env; + if (!trans || !*trans) { ret = FRSH_ERR_BAD_ARGUMENT; goto err; @@ -113,8 +114,17 @@ frsh_transaction_wait_for_name(frsh_transaction_t *transaction, int frsh_transaction_alloc_vres(frsh_transaction_t *t, - int id, + int index, frsh_vres_id_t *vres) { - return FRSH_ERR_NOT_IMPLEMENTED; + int ret; + struct forb_env env; + ret = fres_contract_broker_allocate_transaction_vres( + frsh_forb_global.fcb, (*t)->name, index, &env); + if (forb_exception_occurred(&env)) { + ret = fres_forbex2err(&env); + goto err; + } +err: + return ret; } diff --git a/frsh_api/tests/trans_nego.c b/frsh_api/tests/trans_nego.c index 1fba708..b5a1a75 100644 --- a/frsh_api/tests/trans_nego.c +++ b/frsh_api/tests/trans_nego.c @@ -36,9 +36,10 @@ WVTEST_MAIN("transaction negotiation") WVFRSH(frsh_transaction_add_contract(&t, &contract[i], i)); } + //WVPASS(frsh_transaction_alloc_vres(&t, TEST_CONTRACT_1, &vres1) == FRES_ERR_TRANSACTION_NOT_FOUND); WVFRSH(frsh_transaction_negotiate(&t)); -#if 0 +#if 0 WVFRSH(frsh_transaction_alloc_vres(&t, TEST_CONTRACT_1, &vres1)); WVFRSH(frsh_transaction_alloc_vres(&t, TEST_CONTRACT_2, &vres2)); /* TEST_CONTRACT_3 is allocated in trans_nego2.c */ -- 2.39.2