diff options
author | Haggai Eran <haggai.eran@gmail.com> | 2019-02-19 15:04:42 +0200 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2019-02-19 17:14:24 +0000 |
commit | 46ae2ef0f94c6ac63db22d67196ac764735f0c2e (patch) | |
tree | 3eedf06cd8978d0c1194cb213d250927d0d7108c | |
parent | f1b4e52a6e9f8ec74127da194ec5bbaccd63b87c (diff) |
ldp: return byte count from a successful recvfrom
Unless there's an error, recvfrom should return the number of bytes
received. The current code returns zero on success due to
ldp_copy_ep_to_sockaddr returning zero.
Change-Id: Ib843b99a08c44b5ee2d16efe9edab0cf5df65170
Signed-off-by: Haggai Eran <haggai.eran@gmail.com>
-rw-r--r-- | src/vcl/ldp.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/vcl/ldp.c b/src/vcl/ldp.c index f3ac3107a50..e0fb93534e9 100644 --- a/src/vcl/ldp.c +++ b/src/vcl/ldp.c @@ -1478,7 +1478,7 @@ recvfrom (int fd, void *__restrict buf, size_t n, int flags, __SOCKADDR_ARG addr, socklen_t * __restrict addr_len) { vls_handle_t sid; - ssize_t size; + ssize_t size, rv; if ((errno = -ldp_init ())) return -1; @@ -1495,7 +1495,11 @@ recvfrom (int fd, void *__restrict buf, size_t n, int flags, size = vls_recvfrom (sid, buf, n, flags, &ep); if (size > 0) - size = ldp_copy_ep_to_sockaddr (addr, addr_len, &ep); + { + rv = ldp_copy_ep_to_sockaddr (addr, addr_len, &ep); + if (rv < 0) + size = rv; + } } else size = vls_recvfrom (sid, buf, n, flags, NULL); |