diff --git a/src/network/recvmmsg.c b/src/network/recvmmsg.c index d5dc6b51..2978e2f6 100644 --- a/src/network/recvmmsg.c +++ b/src/network/recvmmsg.c @@ -8,6 +8,8 @@ #define IS32BIT(x) !((x)+0x80000000ULL>>32) #define CLAMP(x) (int)(IS32BIT(x) ? (x) : 0x7fffffffU+((0ULL+(x))>>63)) +hidden void __convert_scm_timestamps(struct msghdr *, socklen_t); + int recvmmsg(int fd, struct mmsghdr *msgvec, unsigned int vlen, unsigned int flags, struct timespec *timeout) { #if LONG_MAX > INT_MAX @@ -19,14 +21,18 @@ int recvmmsg(int fd, struct mmsghdr *msgvec, unsigned int vlen, unsigned int fla #ifdef SYS_recvmmsg_time64 time_t s = timeout ? timeout->tv_sec : 0; long ns = timeout ? timeout->tv_nsec : 0; - int r = -ENOSYS; - if (SYS_recvmmsg == SYS_recvmmsg_time64 || !IS32BIT(s)) - r = __syscall_cp(SYS_recvmmsg_time64, fd, msgvec, vlen, flags, + int r = __syscall_cp(SYS_recvmmsg_time64, fd, msgvec, vlen, flags, timeout ? ((long long[]){s, ns}) : 0); if (SYS_recvmmsg == SYS_recvmmsg_time64 || r!=-ENOSYS) return __syscall_ret(r); - return syscall_cp(SYS_recvmmsg, fd, msgvec, vlen, flags, + if (vlen > IOV_MAX) vlen = IOV_MAX; + socklen_t csize[vlen]; + for (int i=0; i #include "syscall.h" -static void convert_scm_timestamps(struct msghdr *msg, socklen_t csize) +hidden void __convert_scm_timestamps(struct msghdr *, socklen_t); + +void __convert_scm_timestamps(struct msghdr *msg, socklen_t csize) { if (SCM_TIMESTAMP == SCM_TIMESTAMP_OLD) return; if (!msg->msg_control || !msg->msg_controllen) return; @@ -58,7 +60,7 @@ ssize_t recvmsg(int fd, struct msghdr *msg, int flags) } #endif r = socketcall_cp(recvmsg, fd, msg, flags, 0, 0, 0); - if (r >= 0) convert_scm_timestamps(msg, orig_controllen); + if (r >= 0) __convert_scm_timestamps(msg, orig_controllen); #if LONG_MAX > INT_MAX if (orig) *orig = h; #endif