From: Michal Sojka Date: Mon, 21 Jul 2008 12:44:28 +0000 (+0200) Subject: Attempt to fix handling of hello messages X-Git-Url: http://rtime.felk.cvut.cz/gitweb/frescor/fwp.git/commitdiff_plain/069c1e730c2df457cf6e9a8792f26d1adbf1aa31 Attempt to fix handling of hello messages --- diff --git a/fwp/lib/mngt/fwp_contract.c b/fwp/lib/mngt/fwp_contract.c index 7b2dae2..39dfc7c 100644 --- a/fwp/lib/mngt/fwp_contract.c +++ b/fwp/lib/mngt/fwp_contract.c @@ -49,10 +49,9 @@ int fwp_contract_negotiate(fwp_contract_d_t contractd, fwp_vres_d_t *vresdp) } /** - * Creates contract + * Allocates a contract and VRES and inserts the contract to + * contract_table. * - * FIXME: Not very helpful description :) - * * \param[in] contract User-level contract * * \return On success, returns contract descriptor, on error NULL is returned. diff --git a/fwp/lib/mngt/fwp_mngt.c b/fwp/lib/mngt/fwp_mngt.c index b53b956..d28c0c5 100644 --- a/fwp/lib/mngt/fwp_mngt.c +++ b/fwp/lib/mngt/fwp_mngt.c @@ -66,7 +66,7 @@ int fwp_mngt_recv(fwp_msg_type_t *type, fwp_participant_id_t *participant_id, return 0; } -int fwp_mngt_service_vres_create(fwp_vres_d_t* vresdp) +int fwp_mngt_service_vres_create(fwp_contract_d_t* contd, fwp_vres_d_t* vresdp) { fwp_contract_d_t contractd; fwp_contract_data_t* contdata; @@ -96,6 +96,7 @@ int fwp_mngt_service_vres_create(fwp_vres_d_t* vresdp) *vresdp = contdata->vresd; FWP_DEBUG("Service vres negotiated\n"); + *contd = contractd; return 0; } @@ -117,7 +118,8 @@ int fwp_mngt_connect() /* Create discovery endpoint */ FWP_DEBUG("Service vres created\n"); - fwp_mngt_service_vres_create(&fwp_participant_mngr->vresd); + fwp_mngt_service_vres_create(&fwp_participant_mngr->service_contract, + &fwp_participant_mngr->vresd); FWP_DEBUG("Discovery send endpoint created\n"); ret = fwp_send_endpoint_create(fwp_participant_mngr->id.node_id, diff --git a/fwp/lib/mngt/fwp_mngt.h b/fwp/lib/mngt/fwp_mngt.h index b87e7c3..2deb683 100644 --- a/fwp/lib/mngt/fwp_mngt.h +++ b/fwp/lib/mngt/fwp_mngt.h @@ -22,7 +22,7 @@ int fwp_mngt_send(fwp_msg_type_t type,fwp_msgb_t *msgb, int fwp_mngt_recv(fwp_msg_type_t *type, fwp_participant_id_t *participant_id, fwp_msgb_t *msgb); -int fwp_mngt_service_vres_create(fwp_vres_d_t* fwp_service_vresd); +int fwp_mngt_service_vres_create(fwp_contract_d_t* contd, fwp_vres_d_t* vresdp); #endif /* _FWP_INTERNALS_ */ diff --git a/fwp/lib/mngt/fwp_participant.h b/fwp/lib/mngt/fwp_participant.h index 8b17588..704c69b 100644 --- a/fwp/lib/mngt/fwp_participant.h +++ b/fwp/lib/mngt/fwp_participant.h @@ -28,6 +28,7 @@ struct fwp_participant { fwp_participant_id_t id; unsigned int stream_id; fwp_endpoint_d_t epointd; /**< endpoint descriptor for communication*/ + fwp_contract_d_t service_contract; /**< Service contract descriptor */ fwp_vres_d_t vresd; /**< service vres descriptor */ gavl_node_t participant_tree_node; fwp_contract_table_t contract_table; /**< participant`s contract table */ diff --git a/fwp/mngr/fwp_mngr.c b/fwp/mngr/fwp_mngr.c index 25968c8..50fb952 100644 --- a/fwp/mngr/fwp_mngr.c +++ b/fwp/mngr/fwp_mngr.c @@ -1,6 +1,8 @@ #define CONFIGURE_FWP_MY_STREAM_ID 3000 #define CONFIGURE_FWP_MNGR_ADDR "127.0.0.1" +#include +#include #include "fwp_confdefs.h" #include "fwp.h" @@ -90,7 +92,8 @@ int fwp_mngr_hello(fwp_msgb_t *msgb, fwp_participant_id_t participant_id) participant = fwp_participant_new(&participant_info); if (!participant) return -1; - ret = fwp_mngt_service_vres_create(&participant->vresd); + ret = fwp_mngt_service_vres_create(&participant->service_contract, + &participant->vresd); if (ret < 0) goto err_vres; ret = fwp_send_endpoint_create(participant->id.node_id, participant->stream_id, @@ -126,6 +129,7 @@ int fwp_mngr_hello(fwp_msgb_t *msgb, fwp_participant_id_t participant_id) participant_id.node_id, participant_id.app_id); return 0; err_send: + fwp_send_endpoint_unbind(participant->epointd); err_bind: fwp_endpoint_destroy(participant->epointd); err_endpoint: @@ -133,6 +137,7 @@ err_endpoint: * fwp_mngt_service_vres_create(), beacuse it doesn't delete * the service contract. */ fwp_vres_destroy(participant->vresd); + fwp_contract_destroy(participant->service_contract); err_vres: fwp_participant_delete(participant); return -1; @@ -147,7 +152,8 @@ int fwp_mngr_bye(fwp_msgb_t *msgb, fwp_participant_id_t participant_id) if (!(participant = fwp_participant_table_find(&participant_id))){ return -EPERM; } - + + /* TODO: Check for errors */ fwp_participant_table_delete(participant); fwp_send_endpoint_unbind(participant->epointd); fwp_endpoint_destroy(participant->epointd); @@ -301,7 +307,10 @@ void fwp_mngr_msg_handler(fwp_msgb_t *msgb) participant_id.app_id); ret = fwp_mngr_hello(msgb, participant_id); if (ret < 0) { - fwp_mngr_bye(msgb, participant_id); + ret = fwp_mngr_bye(msgb, participant_id); + if (ret < 0) { + error(0, errno, "Cannot send bye"); + } } break;