diff options
author | Joan Lledó <joanlluislledo@gmail.com> | 2019-05-04 10:25:05 +0200 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2019-05-04 10:59:54 +0200 |
commit | 2e90bcdbf1a7c758f13d110833d58d1eecf6dec3 (patch) | |
tree | ab500cd976bf666fdd21a130c27c58bf31d03985 /lwip | |
parent | 1b7c1ca5392f3b950afa28cb07d6703d5497fd93 (diff) | |
download | hurd-2e90bcdbf1a7c758f13d110833d58d1eecf6dec3.tar.gz hurd-2e90bcdbf1a7c758f13d110833d58d1eecf6dec3.tar.bz2 hurd-2e90bcdbf1a7c758f13d110833d58d1eecf6dec3.zip |
lwip: Set output flags when calling recv()
Lwip 2.1.2 added a new function lwip_recvmsg() which writes out flags
for the recv() operation.
* lwip/socket-ops.c: Call lwip_recvmsg() instead of lwip_recvfrom().
Message-Id: <20190504082505.7002-2-jlledom@member.fsf.org>
Diffstat (limited to 'lwip')
-rw-r--r-- | lwip/socket-ops.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/lwip/socket-ops.c b/lwip/socket-ops.c index 9030e477..decba3f8 100644 --- a/lwip/socket-ops.c +++ b/lwip/socket-ops.c @@ -395,10 +395,13 @@ lwip_S_socket_recv (struct sock_user * user, int *outflags, mach_msg_type_number_t amount) { error_t err; - struct sockaddr_storage addr; - socklen_t addrlen = sizeof (addr); + union { struct sockaddr_storage storage; struct sockaddr sa; } addr; int alloced = 0; int sockflags; + struct iovec iov; + struct msghdr m = { msg_name: &addr.sa, msg_namelen:sizeof addr, + msg_controllen: 0, msg_iov: &iov, msg_iovlen:1 + }; if (!user) return EOPNOTSUPP; @@ -416,13 +419,14 @@ lwip_S_socket_recv (struct sock_user * user, alloced = 1; } + iov.iov_base = *data; + iov.iov_len = amount; + sockflags = lwip_fcntl (user->sock->sockno, F_GETFL, 0); if (sockflags & O_NONBLOCK) flags |= MSG_DONTWAIT; - /* TODO: use recvmsg instead */ - err = lwip_recvfrom (user->sock->sockno, *data, amount, - flags, (struct sockaddr *) &addr, &addrlen); + err = lwip_recvmsg (user->sock->sockno, &m, flags); if (err < 0) { @@ -438,13 +442,14 @@ lwip_S_socket_recv (struct sock_user * user, /* Set the peer's address for the caller */ err = - lwip_S_socket_create_address (0, addr.ss_family, (void *) &addr, - addrlen, addrport, addrporttype); + lwip_S_socket_create_address (0, addr.sa.sa_family, + (void *) &addr.sa, m.msg_namelen, + addrport, addrporttype); if (err && alloced) munmap (*data, *datalen); - *outflags = 0; /* FIXME */ + *outflags = m.msg_flags; *nports = 0; *portstype = MACH_MSG_TYPE_COPY_SEND; *controllen = 0; |