[vlc-devel] [PATCH 3/3] access/udp: reduce mtu amount on initial packets

Ilkka Ollakka ileoo at videolan.org
Tue Oct 16 19:42:45 CEST 2018


On Tue, Oct 16, 2018 at 09:10:27AM -0700, Nick Briggs wrote:

> > From: Ilkka Ollakka <ileoo at videolan.org>
> > +        sys->mtu = recv(sys->fd, pkt->p_buffer, sys->mtu, MSG_PEEK|MSG_TRUNC);

> Perhaps I'm confused, but on a non-Linux system (MacOS, [Free|Open]BSD) MSG_TRUNC is not an input flag for a recv() call.
> On those systems MSG_TRUNC is only ever an output flag returned in the msghdr.msg_flags.

You are not confused, I know that the flags in that are most likely not
fully correct. It was tinkered together just to give idea of the flow.


> > +#ifdef __linux__
> > +    const int trunc_flag = MSG_TRUNC;
> > +#else
> > +    const int trunc_flag = 0;
> > +#endif
> > +

> MacOS has the MSG_TRUNC flag, and if you do this you won't be able to check the msg.msg_flags returned value later -- is that what you intended?

No, with this I want to give the trunc_flag to recvmsg as flags. setting
up .msg_flags actually most likely is not needed to fill on before use,
only to check after receive. But on this patch I also changed that I
check the output flags and check that against MSG_TRUNC instead of this
trunc_flag for this reason.

> >     struct iovec iov = {
> >         .iov_base = pkt->p_buffer,
> >         .iov_len = sys->mtu,
> > @@ -238,9 +244,7 @@ static block_t *BlockUDP(stream_t *access, bool *restrict eof)
> >     struct msghdr msg = {
> >         .msg_iov = &iov,
> >         .msg_iovlen = 1,
> > -#ifdef __linux__
> > -        .msg_flags = MSG_TRUNC,
> > -#endif
> > +        .msg_flags = trunc_flag,

> Isn't this an output only field? At least that's what the documentation implies even on Linux.

Yes, I got same impression out when reading the docs few times.


-- 
Ilkka Ollakka
Philosophy:  A route of many roads leading from nowhere to nothing.
		-- Ambrose Bierce
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20181016/b753ef2d/attachment.sig>


More information about the vlc-devel mailing list