]> rtime.felk.cvut.cz Git - frescor/fwp.git/commitdiff
Attempt to fix handling of hello messages
authorMichal Sojka <sojkam1@fel.cvut.cz>
Mon, 21 Jul 2008 12:44:28 +0000 (14:44 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Mon, 21 Jul 2008 12:44:28 +0000 (14:44 +0200)
fwp/lib/mngt/fwp_contract.c
fwp/lib/mngt/fwp_mngt.c
fwp/lib/mngt/fwp_mngt.h
fwp/lib/mngt/fwp_participant.h
fwp/mngr/fwp_mngr.c

index 7b2dae211bcc4302aa91d7da7b761422b1e6b441..39dfc7c700ec0105aedc02f8fe6c91d225f93f9e 100644 (file)
@@ -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.
index b53b9565726686954b7c6e86be03b575eefefb2c..d28c0c5a57c969a6deef4d1d78aafb4776ffb26a 100644 (file)
@@ -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,
index b87e7c31a8c099f47d9b358bca7a8717c2ffe2a2..2deb6835d04fd22f897f468166e76c2f570d07b3 100644 (file)
@@ -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_ */
 
index 8b175881fee04372c6e33ae24d1f97980cec8b15..704c69b7ce7ec9f5b154aa11c2aa487873334517 100644 (file)
@@ -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 */
index 25968c8c53def87e30cecd3dca4cc8d01273fba3..50fb952cc0017fddb43643fcc20a8c69956eb9f5 100644 (file)
@@ -1,6 +1,8 @@
 #define CONFIGURE_FWP_MY_STREAM_ID 3000
 #define CONFIGURE_FWP_MNGR_ADDR "127.0.0.1"
 
+#include <error.h>
+#include <errno.h>
 #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;