summaryrefslogtreecommitdiff
path: root/src/ipcpd/shim-udp
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@intec.ugent.be>2016-05-27 15:36:23 +0200
committerdimitri staessens <dimitri.staessens@intec.ugent.be>2016-05-27 15:36:23 +0200
commit4893bcd941b0b55f1954ac81aade2e53e4a94cd2 (patch)
treec1f73c6d53a8a3a97496fca434bcb2d367d1e9cb /src/ipcpd/shim-udp
parent7d9e6dc52ef4fca6edf8199a3146f09308b57860 (diff)
downloadouroboros-4893bcd941b0b55f1954ac81aade2e53e4a94cd2.tar.gz
ouroboros-4893bcd941b0b55f1954ac81aade2e53e4a94cd2.zip
ipcpd: shim-udp changed to blocking write
The shim UDP did a non-blocking write call, causing loss of SDU's. This has been changed to a blocking write call.
Diffstat (limited to 'src/ipcpd/shim-udp')
-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;