summaryrefslogtreecommitdiff
path: root/src/ipcpd/shim-eth-llc
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@intec.ugent.be>2016-06-30 23:14:14 +0200
committerdimitri staessens <dimitri.staessens@intec.ugent.be>2016-07-02 19:11:12 +0200
commit79475a4742bc28e1737044f2300bcb601e6e10bf (patch)
treecd79dba391c0ded80125836069d8187a22f7e5f5 /src/ipcpd/shim-eth-llc
parentd85f211d53a0cb35a756d0c44a2b28807eff4e5d (diff)
downloadouroboros-79475a4742bc28e1737044f2300bcb601e6e10bf.tar.gz
ouroboros-79475a4742bc28e1737044f2300bcb601e6e10bf.zip
lib: robust locking in shared memory and crash recovery
This PR enhances the shared memory providing recovery if a process crashes. It adds a SHM_DU_TIMEOUT_MICROS variable, setting an expiration time for SDU's when shared memory is full. If an application doesn't read a blocking SDU within this time, the shared memory will be cleansed of all SDU's for this application and the application's rbuff will be cleared. Some refactoring of the API's. Fixed wrong pthread checks in IRMd. Fixes #13 Fixes #14
Diffstat (limited to 'src/ipcpd/shim-eth-llc')
-rw-r--r--src/ipcpd/shim-eth-llc/main.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/ipcpd/shim-eth-llc/main.c b/src/ipcpd/shim-eth-llc/main.c
index 48b6391f..68e7e933 100644
--- a/src/ipcpd/shim-eth-llc/main.c
+++ b/src/ipcpd/shim-eth-llc/main.c
@@ -722,11 +722,12 @@ static void * eth_llc_ipcp_sdu_reader(void * o)
continue;
}
- while ((index =
- shm_create_du_buff(shim_data(_ipcp)->dum,
- frame_len, 0,
- (uint8_t *) (buf + i),
- frame_len)) < 0)
+ while ((index = shm_du_map_write(shim_data(_ipcp)->dum,
+ ipcp_flow(j)->api,
+ 0,
+ 0,
+ (uint8_t *) (buf + i),
+ frame_len)) < 0)
;
e.index = index;
@@ -769,9 +770,9 @@ static void * eth_llc_ipcp_sdu_writer(void * o)
return (void *) 1; /* -ENOTENROLLED */
}
- len = shm_du_map_read_sdu((uint8_t **) &buf,
- shim_data(_ipcp)->dum,
- e->index);
+ len = shm_du_map_read((uint8_t **) &buf,
+ shim_data(_ipcp)->dum,
+ e->index);
if (len <= 0) {
pthread_rwlock_unlock(&_ipcp->state_lock);
free(e);
@@ -798,7 +799,7 @@ static void * eth_llc_ipcp_sdu_writer(void * o)
pthread_rwlock_unlock(&shim_data(_ipcp)->flows_lock);
if (shim_data(_ipcp)->dum != NULL)
- shm_release_du_buff(shim_data(_ipcp)->dum, e->index);
+ shm_du_map_remove(shim_data(_ipcp)->dum, e->index);
pthread_rwlock_unlock(&_ipcp->state_lock);
}