summaryrefslogtreecommitdiff
path: root/src/ipcpd
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@intec.ugent.be>2016-05-27 15:40:50 +0200
committerSander Vrijders <sander.vrijders@intec.ugent.be>2016-05-27 15:40:50 +0200
commitc510fb625427a9329668f83ca115645fa1a36091 (patch)
treec1f73c6d53a8a3a97496fca434bcb2d367d1e9cb /src/ipcpd
parent7d9e6dc52ef4fca6edf8199a3146f09308b57860 (diff)
parent4893bcd941b0b55f1954ac81aade2e53e4a94cd2 (diff)
downloadouroboros-c510fb625427a9329668f83ca115645fa1a36091.tar.gz
ouroboros-c510fb625427a9329668f83ca115645fa1a36091.zip
Merged in dstaesse/ouroboros/be-udp-blockwrite (pull request #117)
ipcpd: shim-udp changed to blocking write
Diffstat (limited to 'src/ipcpd')
-rw-r--r--src/ipcpd/shim-udp/main.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/src/ipcpd/shim-udp/main.c b/src/ipcpd/shim-udp/main.c
index db9a89e2..6869aaf0 100644
--- a/src/ipcpd/shim-udp/main.c
+++ b/src/ipcpd/shim-udp/main.c
@@ -222,26 +222,23 @@ static ssize_t ipcp_udp_flow_write(int fd, void * buf, size_t count)
return -1; /* -ENOTENROLLED */
}
- index = shm_create_du_buff(_ap_instance->dum, count, 0, buf, count);
-
- if (index == -1) {
- return -1;
- }
-
- e.index = index;
-
rw_lock_rdlock(&_ap_instance->flows_lock);
+ while ((index = shm_create_du_buff(_ap_instance->dum,
+ count + DU_BUFF_HEADSPACE +
+ DU_BUFF_TAILSPACE,
+ DU_BUFF_HEADSPACE,
+ (uint8_t *) buf,
+ count)) < 0)
+ ;
+
+ e.index = index;
e.port_id = _ap_instance->flows[fd].port_id;
- if (shm_ap_rbuff_write(_ap_instance->flows[fd].rb, &e) < 0) {
- rw_lock_unlock(&_ap_instance->flows_lock);
- shm_release_du_buff(_ap_instance->dum, index);
- return -EPIPE;
- }
+ while (shm_ap_rbuff_write(_ap_instance->flows[fd].rb, &e) < 0)
+ ;
rw_lock_unlock(&_ap_instance->flows_lock);
-
rw_lock_unlock(&_ipcp->state_lock);
return 0;