summaryrefslogtreecommitdiff
path: root/src/ipcpd/ipcp-data.c
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@intec.ugent.be>2016-05-07 16:11:09 +0200
committerdimitri staessens <dimitri.staessens@intec.ugent.be>2016-05-07 16:11:09 +0200
commiteb9f44379d5316e7f7e9311d7a66d2041eca743a (patch)
tree2489605a42bb2c9582c0c4e912c2de0c40512b2a /src/ipcpd/ipcp-data.c
parentde8f2015cbd015b1cced366cb12c054be62c23b1 (diff)
downloadouroboros-eb9f44379d5316e7f7e9311d7a66d2041eca743a.tar.gz
ouroboros-eb9f44379d5316e7f7e9311d7a66d2041eca743a.zip
irmd: flow allocation and fast path
This commit has a first implementation of flow allocation (the "slow path") and read/write (the "fast path") for ouroboros. It provides basic but unstable communications over the shared memory. It required a lot of changes all over the stack, and fixes a number of previously undetected issues. This PR still need heavy revision regarding data model, locking and cleanup. lib/dev: modifications to the API. It now uses an ap_init() call to set the AP name and sets the Instance ID to the pid of the process. It also binds the AP to the shared memory and creates tables for mappings in the fast path. A call to ap_fini() releases the resources. lib/shm_ap_rbuff: added ring buffer for data exchange between processes in the fast path. It passes an index in the shm_du_map. lib/shm_du_map: rewrote API to work with calls from dev.c. Garbage collector added. Tests updated to new API. ipcpd/ipcp-data: removed everything related to flows, as these are universal for all ap's and kept in ap_data (dev.c), or similar structs for shim ipcps. shim-udp: added flow allocator and read/write functions and shm elements. irmd: revised data model and structures necessary for flow allocation. tools: echo updated to new dev.h API. messaging system was updated to comply with new flow allocation messages. All exchanges use pid and port_id to bootstrap the fast path.
Diffstat (limited to 'src/ipcpd/ipcp-data.c')
-rw-r--r--src/ipcpd/ipcp-data.c104
1 files changed, 1 insertions, 103 deletions
diff --git a/src/ipcpd/ipcp-data.c b/src/ipcpd/ipcp-data.c
index 72407a53..76fc4bcd 100644
--- a/src/ipcpd/ipcp-data.c
+++ b/src/ipcpd/ipcp-data.c
@@ -96,46 +96,26 @@ struct ipcp_data * ipcp_data_create()
if (data == NULL)
return NULL;
- data->iname = NULL;
data->type = 0;
- data->dum = NULL;
return data;
}
struct ipcp_data * ipcp_data_init(struct ipcp_data * dst,
- const char * ipcp_name,
enum ipcp_type ipcp_type)
{
if (dst == NULL)
return NULL;
- dst->iname = instance_name_create();
- if (dst->iname == NULL)
- return NULL;
-
- if(instance_name_init_from(dst->iname, ipcp_name, getpid()) == NULL) {
- instance_name_destroy(dst->iname);
- return NULL;
- }
-
dst->type = ipcp_type;
- dst->dum = shm_du_map_open();
- if (dst->dum == NULL) {
- instance_name_destroy(dst->iname);
- return NULL;
- }
-
/* init the lists */
INIT_LIST_HEAD(&dst->registry);
- INIT_LIST_HEAD(&dst->flows);
INIT_LIST_HEAD(&dst->directory);
/* init the mutexes */
pthread_mutex_init(&dst->reg_lock, NULL);
pthread_mutex_init(&dst->dir_lock, NULL);
- pthread_mutex_init(&dst->flow_lock, NULL);
return dst;
}
@@ -156,42 +136,22 @@ static void clear_directory(struct ipcp_data * data)
dir_entry_destroy(list_entry(h, struct dir_entry, list));
}
-static void clear_flows(struct ipcp_data * data)
-{
- struct list_head * h;
- struct list_head * t;
- list_for_each_safe(h, t, &data->flows)
- flow_destroy(list_entry(h, flow_t, list));
-
-}
-
void ipcp_data_destroy(struct ipcp_data * data)
{
if (data == NULL)
return;
- /* FIXME: finish all pending operations here */
-
- if (data->iname != NULL)
- instance_name_destroy(data->iname);
- data->iname = NULL;
-
- if (data->dum != NULL)
- shm_du_map_close(data->dum);
- data->dum = NULL;
+ /* FIXME: finish all pending operations here and cancel all threads */
pthread_mutex_lock(&data->reg_lock);
pthread_mutex_lock(&data->dir_lock);
- pthread_mutex_lock(&data->flow_lock);
/* clear the lists */
clear_registry(data);
clear_directory(data);
- clear_flows(data);
/*
* no need to unlock, just free the entire thing
- * pthread_mutex_unlock(&data->flow_lock);
* pthread_mutex_unlock(&data->dir_lock);
* pthread_mutex_unlock(&data->reg_lock);
*/
@@ -380,65 +340,3 @@ uint64_t ipcp_data_get_addr(struct ipcp_data * data,
return addr;
}
-
-flow_t * ipcp_data_find_flow(struct ipcp_data * data,
- uint32_t port_id)
-{
- struct list_head * h;
- list_for_each(h, &data->flows) {
- flow_t * f = list_entry(h, flow_t, list);
- if (f->port_id == port_id)
- return f;
- }
-
- return NULL;
-}
-
-bool ipcp_data_has_flow(struct ipcp_data * data,
- uint32_t port_id)
-{
- return ipcp_data_find_flow(data, port_id) != NULL;
-}
-
-int ipcp_data_add_flow(struct ipcp_data * data,
- flow_t * flow)
-{
- if (data == NULL || flow == NULL)
- return -1;
-
- pthread_mutex_lock(&data->flow_lock);
-
- if (ipcp_data_has_flow(data, flow->port_id)) {
- pthread_mutex_unlock(&data->flow_lock);
- return -2;
- }
-
- list_add(&flow->list,&data->flows);
-
- pthread_mutex_unlock(&data->flow_lock);
-
- return 0;
-}
-
-int ipcp_data_del_flow(struct ipcp_data * data,
- uint32_t port_id)
-{
- flow_t * f;
-
- if (data == NULL)
- return -1;
-
- pthread_mutex_lock(&data->flow_lock);
-
- f = ipcp_data_find_flow(data, port_id);
- if (f == NULL)
- return -1;
-
- list_del(&f->list);
-
- free(f);
-
- pthread_mutex_unlock(&data->flow_lock);
-
- return 0;
-}