summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSander Vrijders <[email protected]>2016-07-02 19:15:26 +0200
committerSander Vrijders <[email protected]>2016-07-02 19:15:26 +0200
commitde63f8b37f82ef6a760c7d3dafe2251160e2c114 (patch)
treecd79dba391c0ded80125836069d8187a22f7e5f5 /include
parentcd4d09aae14afe7b0aa0890c61b0ad43e4f23b28 (diff)
parent79475a4742bc28e1737044f2300bcb601e6e10bf (diff)
downloadouroboros-de63f8b37f82ef6a760c7d3dafe2251160e2c114.tar.gz
ouroboros-de63f8b37f82ef6a760c7d3dafe2251160e2c114.zip
Merged in dstaesse/ouroboros/be-shm-robust (pull request #147)
lib: robust locking in shared memory and crash recovery
Diffstat (limited to 'include')
-rw-r--r--include/ouroboros/config.h.in8
-rw-r--r--include/ouroboros/shm_ap_rbuff.h14
-rw-r--r--include/ouroboros/shm_du_map.h34
3 files changed, 22 insertions, 34 deletions
diff --git a/include/ouroboros/config.h.in b/include/ouroboros/config.h.in
index 0dce7acd..6861c6cb 100644
--- a/include/ouroboros/config.h.in
+++ b/include/ouroboros/config.h.in
@@ -26,13 +26,19 @@
#define PROJECT_NAME "@CMAKE_PROJECT_NAME@"
#define PROJECT_VERSION "@PACKAGE_VERSION@"
#define INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@"
-#define _POSIX_C_SOURCE 200112L
+#define _POSIX_C_SOURCE 200809L
#define IPCP_SHIM_UDP_EXEC "@IPCP_SHIM_UDP_TARGET@"
#define IPCP_SHIM_ETH_LLC_EXEC "@IPCP_SHIM_ETH_LLC_TARGET@"
#define IPCP_NORMAL_EXEC "@IPCP_NORMAL_TARGET@"
#define IPCP_LOCAL_EXEC "@IPCP_LOCAL_TARGET@"
#define AP_MAX_FLOWS 256
+#define SHM_DU_BUFF_BLOCK_SIZE sysconf(_SC_PAGESIZE)
+#define SHM_DU_MAP_FILENAME "ouroboros_du_map"
+#define SHM_BLOCKS_IN_MAP (1 << 14)
+#define SHM_DU_TIMEOUT_MICROS 2000
#define DU_BUFF_HEADSPACE 128
#define DU_BUFF_TAILSPACE 0
+#define SHM_AP_RBUFF_PREFIX "ouroboros_rb_"
+#define SHM_RBUFF_SIZE (1 << 14)
#endif
diff --git a/include/ouroboros/shm_ap_rbuff.h b/include/ouroboros/shm_ap_rbuff.h
index 053709bb..78926869 100644
--- a/include/ouroboros/shm_ap_rbuff.h
+++ b/include/ouroboros/shm_ap_rbuff.h
@@ -24,15 +24,8 @@
#ifndef OUROBOROS_SHM_AP_RBUFF_H
#define OUROBOROS_SHM_AP_RBUFF_H
-#ifndef SHM_AP_RBUFF
-#define SHM_AP_RBUFF_PREFIX "ouroboros_rb_"
-#endif
-
-#ifndef SHM_RBUFF_SIZE
-#define SHM_RBUFF_SIZE (1 << 14)
-#endif
-
#include <sys/types.h>
+#include <stdbool.h>
struct shm_ap_rbuff;
@@ -42,7 +35,7 @@ struct rb_entry {
};
struct shm_ap_rbuff * shm_ap_rbuff_create();
-struct shm_ap_rbuff * shm_ap_rbuff_open();
+struct shm_ap_rbuff * shm_ap_rbuff_open(pid_t api);
void shm_ap_rbuff_close(struct shm_ap_rbuff * rb);
void shm_ap_rbuff_destroy(struct shm_ap_rbuff * rb);
int shm_ap_rbuff_write(struct shm_ap_rbuff * rb,
@@ -50,5 +43,6 @@ int shm_ap_rbuff_write(struct shm_ap_rbuff * rb,
struct rb_entry * shm_ap_rbuff_read(struct shm_ap_rbuff * rb);
ssize_t shm_ap_rbuff_read_port(struct shm_ap_rbuff * rb,
int port_id);
-
+pid_t shm_ap_rbuff_get_api(struct shm_ap_rbuff * rb);
+void shm_ap_rbuff_reset(struct shm_ap_rbuff * rb);
#endif /* OUROBOROS_SHM_AP_RBUFF_H */
diff --git a/include/ouroboros/shm_du_map.h b/include/ouroboros/shm_du_map.h
index 2d215651..e8934bae 100644
--- a/include/ouroboros/shm_du_map.h
+++ b/include/ouroboros/shm_du_map.h
@@ -24,18 +24,6 @@
#ifndef OUROBOROS_SHM_DU_MAP_H
#define OUROBOROS_SHM_DU_MAP_H
-#ifndef SHM_DU_BUFF_BLOCK_SIZE
-#define SHM_DU_BUFF_BLOCK_SIZE sysconf(_SC_PAGESIZE)
-#endif
-
-#ifndef SHM_DU_MAP_FILENAME
-#define SHM_DU_MAP_FILENAME "ouroboros_du_map"
-#endif
-
-#ifndef SHM_BLOCKS_IN_MAP
-#define SHM_BLOCKS_IN_MAP (1 << 14)
-#endif
-
#include "common.h"
#include <sys/types.h>
#include <pthread.h>
@@ -51,18 +39,18 @@ pid_t shm_du_map_owner(struct shm_du_map * dum);
void * shm_du_map_sanitize(void * o);
/* returns the index of the buffer in the DU map */
-ssize_t shm_create_du_buff(struct shm_du_map * dum,
- size_t size,
- size_t headspace,
- uint8_t * data,
- size_t len);
+ssize_t shm_du_map_write(struct shm_du_map * dum,
+ pid_t dst_api,
+ size_t headspace,
+ size_t tailspace,
+ uint8_t * data,
+ size_t data_len);
-/* FIXME: revise these */
-int shm_du_map_read_sdu(uint8_t ** dst,
- struct shm_du_map * dum,
- ssize_t idx);
-int shm_release_du_buff(struct shm_du_map * dum,
- ssize_t idx);
+int shm_du_map_read(uint8_t ** dst,
+ struct shm_du_map * dum,
+ ssize_t idx);
+int shm_du_map_remove(struct shm_du_map * dum,
+ ssize_t idx);
/* FIXME: use shm_du_map * and index */
uint8_t * shm_du_buff_head_alloc(struct shm_du_buff * sdb,