diff options
author | dimitri staessens <dimitri.staessens@ugent.be> | 2017-04-26 11:17:39 +0000 |
---|---|---|
committer | Sander Vrijders <sander.vrijders@ugent.be> | 2017-04-26 11:17:39 +0000 |
commit | ad522c14994ae19c5a6507ee10ebcacdbf3cf107 (patch) | |
tree | 4e4d3b4f8da805ca9f0f0733977ff678c064660f /src/lib/dev.c | |
parent | ea16fc664673d65c0e3e51591258be4d3b8be406 (diff) | |
parent | e2c8623e66d66f4b9c8619349d11375a32ac2134 (diff) | |
download | ouroboros-ad522c14994ae19c5a6507ee10ebcacdbf3cf107.tar.gz ouroboros-ad522c14994ae19c5a6507ee10ebcacdbf3cf107.zip |
Merged in dstaesse/ouroboros/be-shm-reserve (pull request #493)
lib: Add call to reserve blocks in rdrbuff
Diffstat (limited to 'src/lib/dev.c')
-rw-r--r-- | src/lib/dev.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/lib/dev.c b/src/lib/dev.c index 757f26a8..c46cd407 100644 --- a/src/lib/dev.c +++ b/src/lib/dev.c @@ -1430,6 +1430,32 @@ int ipcp_flow_write(int fd, return 0; } +int ipcp_sdb_reserve(struct shm_du_buff ** sdb, + size_t len) +{ + struct shm_rdrbuff * rdrb; + ssize_t idx; + + pthread_rwlock_rdlock(&ai.data_lock); + + rdrb = ai.rdrb; + + pthread_rwlock_unlock(&ai.data_lock); + + idx = shm_rdrbuff_write_b(rdrb, + DU_BUFF_HEADSPACE, + DU_BUFF_TAILSPACE, + NULL, + len); + + if (idx < 0) + return -1; + + *sdb = shm_rdrbuff_get(rdrb, idx); + + return 0; +} + int ipcp_flow_fini(int fd) { struct shm_rbuff * rx_rb; @@ -1539,7 +1565,7 @@ int ipcp_read_shim(int fd, return 0; } -void ipcp_flow_del(struct shm_du_buff * sdb) +void ipcp_sdb_release(struct shm_du_buff * sdb) { shm_rdrbuff_remove(ai.rdrb, shm_du_buff_get_idx(sdb)); } |