]> rtime.felk.cvut.cz Git - frescor/fwp.git/commitdiff
Compilation fixes
authorMartin <molnam1@fel.cvut.cz>
Mon, 13 Oct 2008 16:03:58 +0000 (18:03 +0200)
committerMartin <molnam1@fel.cvut.cz>
Mon, 13 Oct 2008 16:03:58 +0000 (18:03 +0200)
fwp/lib/core/fwp_endpoint.c
fwp/lib/core/fwp_endpoint.h
fwp/lib/core/fwp_vres.c
fwp/lib/core/fwp_vres.h
fwp/tests/Makefile.omk
fwp/tests/fwp_vrestest/Makefile.omk
fwp/tests/fwp_vrestest/fwp_vrestest1.c

index db91bc3e48909c7537d6d1ffa6edd692a07497ee..939335069851ba86f73de144b21fe5ef0e011d15 100644 (file)
@@ -291,12 +291,12 @@ err:
  *
  * \return On success returns 0. On error, -1 and errno is set appropriately.
  */
-int fwp_send_endpoint_bind(fwp_endpoint_t *epoint, fwp_vres_d_t vresd)
+int fwp_send_endpoint_bind(fwp_vres_d_t vresd, fwp_endpoint_t *epoint)
 {
        int rv ;
        fwp_endpoint_t *fwp_epoint = epoint;
        
-       rv = _fwp_vres_bind(vresd, fwp_epoint->sockd);
+       rv = fwp_vres_bind(vresd, fwp_epoint->sockd);
        /* if send endpoint is already bound 
        if (epoint->type == FWP_EPOINT_BOUND) {  
                fwp_send_endpoint_unbind(epoint);
@@ -318,7 +318,7 @@ int fwp_send_endpoint_unbind(fwp_endpoint_d_t epointd)
        fwp_endpoint_t *fwp_epoint = epointd;
 
        /* unlink epoint-vres mutually */
-       if ((rv = _fwp_vres_unbind(fwp_epoint->vresd)) < 0) 
+       if ((rv = fwp_vres_unbind(fwp_epoint->vresd)) < 0) 
                return rv;
 
        return 0;
@@ -501,6 +501,6 @@ int fwp_send(fwp_endpoint_t *fwp_epoint,const void *msg, const size_t size, int
        /*}*/
 
        /* TODO: test whether _fwp_vres_send is successful */
-       return _fwp_vres_send(fwp_epoint->vresd, msgb);
+       return fwp_vres_send(fwp_epoint->vresd, msgb);
 }
 
index 855fa0e09229031db531134aabe34ecff9f6fb33..dbdae604c3322bc3af233286aa829ea90dbe63b7 100644 (file)
@@ -37,7 +37,7 @@ int fwp_receive_endpoint_create(/*unsigned int node,*/ unsigned int port,
                                fwp_endpoint_t **epoint);
 int fwp_endpoint_destroy(fwp_endpoint_d_t epointd);
 
-int fwp_send_endpoint_bind(fwp_endpoint_d_t epointd, fwp_vres_d_t vresd);
+int fwp_send_endpoint_bind(fwp_vres_d_t vresd, fwp_endpoint_d_t epointd);
 int fwp_send_endpoint_unbind(fwp_endpoint_d_t epointd);
 
 ssize_t fwp_recv(fwp_endpoint_t *endpoint,
index e94f1461a964f21de004124d8dda19d5fab9f8a7..d4e15d43d3e3b3491acff0eafd9bf9325c121789 100644 (file)
@@ -10,7 +10,7 @@ static void* fwp_vres_tx_thread(void *_vres);
 
 typedef enum {
        FWP_VF_USED             = 1 ,
-       FWP_VF_ACTIVE           = 2 ,
+       FWP_VF_BOUND            = 2 ,
        FWP_VF_RESCHED          = 4 ,
 } fwp_vres_flag_t;
 
@@ -75,14 +75,14 @@ static inline int fwp_vres_set_ac(int sockd, fwp_ac_t ac_id)
        return 0;
 }
 
-static inline int fwp_vres_set_flag(fwp_vres_t *vres, fwp_vres_flag_t flag)
+static inline void fwp_vres_set_flag(fwp_vres_t *vres, fwp_vres_flag_t flag)
 {
-       return (vres->flags | (1 << flag));
+       vres->flags |= (1 << flag);
 }
 
-static inline int fwp_vres_clear_flag(fwp_vres_t *vres, fwp_vres_flag_t flag)
+static inline void fwp_vres_clear_flag(fwp_vres_t *vres, fwp_vres_flag_t flag)
 {
-       return (vres->flags & ~(1 << flag));
+       vres->flags &= ~(1 << flag);
 }
 
 static inline int fwp_vres_get_flag(fwp_vres_t *vres, fwp_vres_flag_t flag)
@@ -90,6 +90,11 @@ static inline int fwp_vres_get_flag(fwp_vres_t *vres, fwp_vres_flag_t flag)
        return !!(vres->flags & (1 << flag));
 }
 
+static inline void fwp_vres_clearall_flag(fwp_vres_t *vres)
+{
+       vres->flags = 0;
+}
+
 #if 0
 /* Deprecated */
 static int fwp_vres_ac_open(fwp_ac_t ac_id) 
@@ -121,7 +126,7 @@ static int fwp_vres_ac_open(fwp_ac_t ac_id)
 }
 #endif
 
-static inline int __fwp_vres_send(unsigned int ac_sockd, struct fwp_msgb* msgb)
+static inline int _fwp_vres_send(unsigned int ac_sockd, struct fwp_msgb* msgb)
 {
        /*_fwp_sendto(ac_sockd, msgb->data, msgb->len, 0, 
                        msgb->peer->addr, msgb->peer->addrlen);*/
@@ -130,7 +135,7 @@ static inline int __fwp_vres_send(unsigned int ac_sockd, struct fwp_msgb* msgb)
 
 static inline void fwp_vres_free(fwp_vres_t *vres)
 {
-       fwp_vres_clear_flag(vres, FWP_VF_USED);
+       fwp_vres_clearall_flag(vres);
 }
 
 static inline int fwp_vres_is_valid(fwp_vres_t *vres)
@@ -205,6 +210,8 @@ fwp_vres_d_t fwp_vres_alloc()
 
 inline int _fwp_vres_set_params(fwp_vres_t *vres, fwp_vres_params_t *params)
 {
+       int rv;
+
        /* copy vres paramters into vres structure */
        rv = fwp_vres_set_ac(vres->ac_sockd, params->ac_id);
        if (!rv)
@@ -228,14 +235,13 @@ inline int _fwp_vres_set_params(fwp_vres_t *vres, fwp_vres_params_t *params)
 int fwp_vres_set_params(fwp_vres_d_t vresd, fwp_vres_params_t *params)
 {
        fwp_vres_t *vres = vresd;
-       int rv;
        
        if (!fwp_vres_is_valid(vres)) {
                errno = EINVAL;
                return -1;
        }
 
-       return fwp_vres_set_params(vres, params);
+       return _fwp_vres_set_params(vres, params);
 }
 
 /**
@@ -253,29 +259,25 @@ int fwp_vres_create(fwp_vres_params_t *params, fwp_vres_d_t *vresdp)
        int rv;
        fwp_vres_t *vres;
        
-       /* Check for validity of the contract */
-
        vres = fwp_vres_alloc();
        if (!vres) {
                return -1;
        }
-       /* copy vres paramters into vres structure */
-       memcpy(&vres->params, params, sizeof(struct fwp_vres_params));
        /* initialize msg queue */
        fwp_msgq_init(&vres->tx_queue);
        
+       _fwp_vres_set_params(vres, params);
        pthread_attr_init(&vres->tx_thread_attr);
        if ((rv = pthread_create(&vres->tx_thread, &vres->tx_thread_attr, 
                            fwp_vres_tx_thread, (void*) vres)) != 0){
                goto err;
 
        }
-       _fwp_vres_set_params    
+
        *vresdp = vres;
        return 0;
 err:   
        fwp_vres_free(vres);
-       errno = rv;
        return -1; 
 }
 
@@ -299,7 +301,7 @@ int fwp_vres_destroy(fwp_vres_d_t vresd)
        }
        
        pthread_cancel(vres->tx_thread);
-       
+               
        FWP_DEBUG("Vres vparam_id=%d destroyed.\n", vres->params.id);   
        return  0;
 }
@@ -337,8 +339,8 @@ static void* fwp_vres_tx_thread(void *_vres)
        struct fwp_msgb *msgb = NULL;
        unsigned int    ac_id = vres->params.ac_id;
        /*unsigned int  ac_sockd = vres->ac_sockd;*/
-       int             budget = vres->params.budget;
-       int             curr_budget;
+       fwp_budget_t    budget = vres->params.budget;
+       fwp_budget_t    curr_budget;
        int             rc;
                
        struct timespec  start_period, end_period, period;
@@ -372,7 +374,7 @@ static void* fwp_vres_tx_thread(void *_vres)
                curr_budget = 0;
                while ((curr_budget < budget)&& 
                       (msgb = fwp_msgq_dequeue(msgq))) {
-                       rc = __fwp_vres_send(vres->ac_sockd, msgb);
+                       rc = _fwp_vres_send(vres->ac_sockd, msgb);
                        if (!(rc < 0)) {
                                FWP_DEBUG("Message sent through AC%d\n",ac_id);
                                /* Switch to this in the future
@@ -400,7 +402,7 @@ static void* fwp_vres_tx_thread(void *_vres)
        return NULL;
 }
 
-int _fwp_vres_send(fwp_vres_d_t vresd, struct fwp_msgb* msgb)
+int fwp_vres_send(fwp_vres_d_t vresd, struct fwp_msgb* msgb)
 {
        fwp_vres_t *vres = vresd;
 
@@ -412,9 +414,8 @@ int _fwp_vres_send(fwp_vres_d_t vresd, struct fwp_msgb* msgb)
        }
 }
 
-#if 0
-/*int _fwp_vres_bind(fwp_vres_d_t vresd, fwp_endpoint_t *epoint)*/
-int _fwp_vres_bind(fwp_vres_d_t vresd, int sockd)
+/*int fwp_vres_bind(fwp_vres_d_t vresd, fwp_endpoint_t *epoint)*/
+int fwp_vres_bind(fwp_vres_d_t vresd, int sockd)
 {
        fwp_vres_t *vres = vresd;
        int rv = 0;
@@ -426,21 +427,23 @@ int _fwp_vres_bind(fwp_vres_d_t vresd, int sockd)
                goto err;
        }
 
-       if (vres->status != FWP_VRES_UNBOUND) { /*if already bounded */
+       if (fwp_vres_get_flag(vres, FWP_VF_BOUND)) { /*if already bounded */
                errno = EPERM;  
                rv = -1;
                goto err;
        }
 
        vres->ac_sockd = sockd;
-       fwp_vres_set_ac(vres->ac_sockd,vres->params.ac_id);
-       vres->status = FWP_VRES_BOUND;
+       rv = fwp_vres_set_ac(vres->ac_sockd,vres->params.ac_id);
+       if (rv)
+               goto err;
+       fwp_vres_set_flag(vres, FWP_VF_BOUND);
 err:
        pthread_mutex_unlock(&fwp_vres_table.lock);
        return rv;
 }
 
-int _fwp_vres_unbind(fwp_vres_d_t vresd)
+int fwp_vres_unbind(fwp_vres_d_t vresd)
 {
        fwp_vres_t *vres = vresd;
        
@@ -448,10 +451,8 @@ int _fwp_vres_unbind(fwp_vres_d_t vresd)
                errno = EINVAL;
                return -1;
        }
-       vres->status = FWP_VRES_UNBOUND;
+       fwp_vres_clear_flag(vres, FWP_VF_BOUND);
        /* TODO: consider what to do with pending messages */
        /* fwp_vres_free_msgb(vres->tx_queue); */
-       
        return 0;
 }
-#endif
index 183d155933e3d8e949580f2ff26b4b44b7f23691..6638c7d9da3ecc3fff18fcff8cd94a82f6d85dbc 100644 (file)
@@ -46,12 +46,11 @@ fwp_vres_id_t fwp_vres_get_id(fwp_vres_d_t vresd);
 int fwp_vres_set_params(fwp_vres_d_t vresd, fwp_vres_params_t *params);
 int fwp_vres_create(fwp_vres_params_t *params, fwp_vres_d_t *vresdp);
 int fwp_vres_destroy(fwp_vres_d_t vresd);
-/* */
 
-int _fwp_vres_send(fwp_vres_d_t vresd, struct fwp_msgb* msgb);
+int fwp_vres_send(fwp_vres_d_t vresd, struct fwp_msgb* msgb);
 /*int _fwp_vres_bind(fwp_vres_d_t vresd, fwp_endpoint_d_t epointd);*/
-int _fwp_vres_bind(fwp_vres_d_t vresd, int sockd);
-int _fwp_vres_unbind(fwp_vres_d_t vresd);
+int fwp_vres_bind(fwp_vres_d_t vresd, int sockd);
+int fwp_vres_unbind(fwp_vres_d_t vresd);
 
 #endif /* _FWP_INTERNALS_ */
 #endif /* _FWP_VRES_H */
index 5d10f83d3c00e9928fcb2c4007531694cc8fbc59..dc3977549ae20a9bc3f1e98e7191b88e1bc6b3b4 100644 (file)
@@ -1,5 +1,5 @@
-SUBDIRS= fwp_msgtest 
-#fwp_vrestest fwp_prototest fwp_mngrtest  
+SUBDIRS= fwp_msgtest fwp_vrestest 
+#fwp_prototest fwp_mngrtest  
 CFLAGS += -Wall -D_REENTRANT -g
 #SUBDIRS= fwp_msgtest fwp_vrestest fwp_prototest fwp_mngrtest  
 #fwp_mngrtest unixsocktest
index 45879d39640b14d4d7649d61d3feea8233e66925..8023964b052b30a0c9d34e31e76ff6472a5abe8b 100644 (file)
@@ -1,5 +1,5 @@
-test_PROGRAMS = fwp_vrestest1 fwp_vrestest2
+test_PROGRAMS = fwp_vrestest1 
 CFLAGS+= -D_FWP_INTERNALS_
 fwp_vrestest1_SOURCES+= fwp_vrestest1.c
-fwp_vrestest2_SOURCES+= fwp_vrestest2.c
+#fwp_vrestest2_SOURCES+= fwp_vrestest2.c
 lib_LOADLIBES += fwp pthread rt ulut 
index 8882f360ab6f8a05e1393dc7e8e4c5a9ff6ea90c..85effe892dd8e2e9068faf816ddef6f905a957cc 100644 (file)
@@ -67,7 +67,7 @@ int main()
                return -1;
        }
        printf("Send endpoint 1 created\n");
-       fwp_send_endpoint_bind(sepoint_d1, vresd1);
+       fwp_send_endpoint_bind(vresd1, sepoint_d1);
        
        for (count = 0; count < NUM; count++) { 
                sprintf(msg1,"msg%d",count);