On Wed, Jan 20, 2016 at 10:29:47AM +0200, Boris Astardzhiev wrote: > Let me know the final decision then - whether in the existing manpages or > in new files. Decide it yourself, it is your patch. If you are fine with writing new man page, I do not object.
> > jt>The Linux version has an additional parameter struct timespec *timeout > jt>(but only for recvmmsg, not for sendmmsg). Note that implementing this > jt>in a Linux-compatible manner has low overhead, since Linux only checks > jt>it between packets and never interrupts a wait because of this timeout > jt>(source: http://man7.org/linux/man-pages/man2/recvmmsg.2.html ). > > That's right. Shall I try to implement the timeout part or leave > it the way it is now? I do not see any sense in making the functions with signature or semantic different from Linux version. Right now, the goal of including the patch is compatibility. > > kb>Shouldn't i and rcvd be unsigned as well ? Shouldn't return value > kb>also be unsigned ? > I think i and rcvd should be unsigned whereas ret should not - after all > if an error occurred we get -1. I looked at the real signatures and man pages for the Linux functions, finally. There is indeed the timeout arg, the MSG_WAITFORONE flag for recvmmsg(3), and Linux uses ints for what would be naturally size_t. > kb>> + > kb>> + rcvd = 0; > kb>> + for (i = 0; i < vlen; i++) { > kb>> + errno = 0; > kb>> + ret = __sys_recvmsg(s, &msgvec[i].msg_hdr, flags); > kb>> + if (ret < 0 || errno != 0) { > kb>I do not see why do you need to clear errno before, and then do this > test. > kb>Just check ret == -1, in which case errno was set from the immediate > syscall. > kb> > kb>> + if (rcvd != 0) { > kb>> + /* We've received messages. Let caller > know. */ > kb>> + errno = 0; > kb>This cleaning is not needed as well. For successfull functions returns, > kb>errno value is undefined. > > Wouldn't I confuse apps if they check errno in the follow case - I want to > receive two messages. The first __sys_recvmsg succeeds and then for the > second __sys_recvmsg fails. Thus errno will be != 0 and I'm telling the app > that I have received one message by returning 1 but errno will be != 0. > Is this correct? errno value is only defined after the function explicitely returned error. Apps which test for errno without testing for error are wrong. _______________________________________________ freebsd-net@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-net To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"