summaryrefslogtreecommitdiff
path: root/src/lib/shm_du_map.c
Commit message (Collapse)AuthorAgeFilesLines
* lib: shm_du_map: Fix wrong paddingdimitri staessens2016-08-061-3/+3
| | | | Padding was miscalculated, causing lockups in the fast path.
* lib:shm_du_map: Fix wrong element accessdimitri staessens2016-08-051-4/+5
| | | | The check whether the du map is empty should be first.
* lib: shm_du_map: Fix disabling MULTI_BLOCKdimitri staessens2016-08-041-2/+2
|
* lib: shm_du_map: Fix memory leakdimitri staessens2016-08-041-3/+2
|
* lib: Revise blocking I/Odimitri staessens2016-08-031-61/+149
| | | | | | | | | Blocking I/O now uses condition variables in the shared memory instead of busy waiting. Timeouts can be specified. This requires the size of the rbuffs and du_map to be the same, to guarantee that when the shm_du_map is not full, the ap_rbuffs can't be full either. Added the timeout option to the flow for future use.
* lib: dev: Add select-like calldimitri staessens2016-08-031-3/+3
| | | | | | | This adds a flow_select() call that will sleep until an SDU can be read on a flow. It returns the file descriptor for which an SDU is ready. It takes as optional argument a timespec struct to specify a timeout.
* lib: Portability to FreeBSDdimitri staessens2016-07-291-2/+2
| | | | | | | | | | Various portability fixes for FreeBSD. POSIX requires shm file names to start with a "/" to be portable. lseek(2) can be undefined on POSIX shm, replaced with ftruncate(2). IRMd check on existing lockfile more portable. FreeBSD 11.0 is preferred as it natively supports robust mutexes. Full working LLC implementation pending.
* lib: shm_du_map: PCI allocation / deallocationdimitri staessens2016-07-111-34/+90
| | | | | | Correct implementation of allocation for the Protocol Control Information. Also removes stale code checking for a corner case when the du map still wrapped multi-block SDU's.
* ouroboros: Use ouroboros errno.hdimitri staessens2016-07-071-1/+1
| | | | | All includes of <errno.h> within ouroboros are replaced with the ouroboros errno.
* lib: Add lockfiledimitri staessens2016-07-071-8/+2
| | | | | | | | | | | | The pid of the IRMd is stored in a lockfile in shared memory. This makes checking if the IRMd is running independent of the configuration, as previously the IRMd pid was stored at the end of the shm_du_map, which could not be read by an IRMd that would be compiled with different configuration options. Also corrects some unnecessary includes Fixes #21.
* lib: shm_du_map: Fix cleaning stale DU mapdimitri staessens2016-07-061-1/+1
| | | | | Added check if the owner of the du map is actually running so a new IRMd instance can remove a stale DU map.
* lib: shm_du_map: Don't open rbuff when process exitsdimitri staessens2016-07-061-5/+5
| | | | | clean_sdus now has a boolean flag to let it know the process has exited.
* lib: shm_du_map: Clean sdus upon exitdimitri staessens2016-07-061-2/+27
| | | | | | | | When an application closes the shm_du_map, it will clean all remaining sdu's for that application. Adds a function to clean the shm_du_map on close. Fixes #20.
* lib: Change invalid pid to -1dimitri staessens2016-07-051-6/+6
| | | | | | | | The stack used pid 0 (the scheduler) to indicate an invalid process instance, probably as a leftover from the deprecated application process instance id. Using -1 is a better solution. Fixes #16.
* lib: Provide first implementation of revised CDAPSander Vrijders2016-07-051-0/+1
| | | | | | | | This commit introduces a first version of the revised CDAP specification. CACEP (for authentication purposes) has been separated from CDAP. Application developers may use CDAP if they find it useful. Within Ouroboros CDAP will be used to perform operations on the RIB of an IPCP.
* lib: shm_du_map full multi-block supportdimitri staessens2016-07-031-103/+79
| | | | | | | shm_du_map now fully supports multi-block SDU's when the SHM_DU_MAP_MULTI_BLOCK compilation flag is set (enabled by default). Fixes #11.
* lib: robust locking in shared memory and crash recoverydimitri staessens2016-07-021-63/+194
| | | | | | | | | | | | | | 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
* lib, irmd, ipcpd: Change pid to apiSander Vrijders2016-06-281-5/+5
| | | | Changes the variable name as well to API instead of PID.
* lib, irmd, ipcp: robust mutexesdimitri staessens2016-06-211-7/+25
| | | | | | | | Update to POSIX 200112L to allow use of robust mutexes in the shm_du_map. Removed the implementation of the rw_lock in favor of pthread_rwlock_t. Placeholder for the shm_du_map_sanitize function.
* build: Change install directories and set correct permissionsSander Vrijders2016-06-201-0/+8
| | | | | | | | | This sets the correct install directories for all the binaries, library and header files. It also sets the right permissions on the sockets and shared memory so that regular users can also use the ouroboros library. Root privileges are required to run the irmd. Fixes #7
* irmd, lib: use shm_du_map as lockfile.dimitri staessens2016-06-171-9/+15
| | | | | | | | | | | | Added the pid of the irmd to the shm_du_map. The IRMd will check for an existing shm_du_map. If there is an existing file, it will exit if the owner IRMd is running or remove it if the owner IRMd is not running. Also simplifies calculation of the shm_du_map pointers and corrects exiting calls for the IRMd. Fixes #8.
* lib: fixed SHM_DU_BUFF_BLOCK_SIZE in shm_du_mapdimitri staessens2016-05-261-1/+1
|
* lib: allow running shm_du_map in single block modedimitri staessens2016-05-251-6/+31
| | | | | this allows disabling support for SDU's that are larger than a block in the DU MAP by defining the variable SHM_MAP_SINGLE_BLOCK
* lib: Add missing check upon garbage collectionSander Vrijders2016-05-171-2/+3
| | | | | | | There was a check missing upon garbage collection. If the whole DU map has been used once, all DUs will have their garbage bit set to one. This meant that the garbage collector would keep moving the tail indefinitely.
* lib: Fixed incorrect initializationSander Vrijders2016-05-171-3/+4
| | | | | When moving the tail pointer in the DU map, blocks was never reset to zero. This caused it to sometimes clean up too many DUs.
* lib: Add missing modulo calculationSander Vrijders2016-05-161-10/+10
| | | | | | Adds a missing modulo calculation that would result in index -1 being returned instead of zero when the ringbuffer skipped back to the beginning.
* lib: cleanup file descriptors for shared memorydimitri staessens2016-05-151-0/+6
| | | | | cleanup of file descriptors for the shared memory. also adds a missing NULL check and some invalidation in dev.c
* lib/test: removed the test for the shm_du_mapdimitri staessens2016-05-091-2/+1
| | | | | | | The test had a synchronisation issue. Due to rebuild of the shm_du_map for random access, there was also a hack in the shm_du_map specifically to run this test. Because of this hack, the decision was made to drop this test.
* irmd: flow allocation and fast pathdimitri staessens2016-05-071-39/+104
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* lib: include stdlib.h, not malloc.hdimitri staessens2016-04-021-1/+1
|
* lib/ipcpd: fixed logging mistakedimitri staessens2016-03-251-0/+5
| | | | logs should be included in source, not in header
* lib: Shared Memorydimitri staessens2016-03-241-134/+68
| | | | | | | | Updated tests. Added code to drop a corner case (packet where the tail PCI would cross the edge of the ring buffer) because solving this very rare case is not worth the performance hit on the ringbuffer the extra code would incur. This means the ringbuffer might drop a very small percentage of packets.
* lib: optimization of ringbufferDimitri Staessens2016-03-201-15/+14
| | | | | | | | Got rid of divisions and modulo operations. Change in the meaning of a #define. SHM_DU_MAP_SIZE: is now an exponent of 2. Default is 10, allowing for 1024 blocks in the map.
* lib: updated shm_du_map to be a hybrid ring bufferDimitri Staessens2016-03-191-127/+67
| | | | | | Elements must be created/destroyed in order, but IPCPs can access PCI while the PDU is in the ring buffer. Test updated, no more waits are needed.
* lib: shared memory mapDimitri Staessens2016-03-191-0/+493
The shared memory map will allow passing SDU's between IPCPs efficiently. It is a single block of managed memory. SDU's are stored in a shm_du_buff datastructure, which is a list of blocks inside the shared memory region. The mechanism for passing SDU's is not yet implemented and could be either within the region or using another local IPC mechanism. The following things are configured at compile time: SHM_FILE_NAME : the name. Default is "ouroboros_du_map". SHM_DU_BUFF_BLOCK_SIZE: size of a block inside the shared memory region. Default is the pagesize of the system. SHM_DU_MAP_SIZE : the approximate size in bytes of the shared memory map. The actual filesize may differ by a small margin. Default is 4MB.