Re: behavior of recvmmsg() on blocking sockets

From: Chris Friesen
Date: Mon Mar 29 2010 - 12:21:32 EST


On 03/27/2010 07:19 AM, Brandon Black wrote:

> I've been playing with the timeout argument to recvmmsg as well now,
> and I'm struggling to see how one would ever use it correctly with the
> current implementation.

I'd probably do something like this:

prev = current time
loop forever
cur = current time
timeout = max_latency - (cur - prev)
recvmmsg(timeout)
process all received messages
prev = cur


Basically you determine the max latency you're willing to wait for a
packet to be handled, then subtract the amount of time you spent
processing messages from that and pass it into the recvmmsg() call as
the timeout. That way no messages will be delayed for longer than the
max latency. (Not considering scheduling delays.)

Chris
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/