From 4893bcd941b0b55f1954ac81aade2e53e4a94cd2 Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Fri, 27 May 2016 15:36:23 +0200 Subject: 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. --- src/ipcpd/shim-udp/main.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'src') 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; -- cgit v1.2.3